Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace 'blacklist' and 'whitelist' with 'blocked' and 'allowed' (#1077) (CP: 19.1) #1080

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
server.port=8888
vaadin.blacklisted-packages=vaadin-spring/target/test-classes
vaadin.blocked-packages=vaadin-spring/target/test-classes
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (C) 2000-2023 Vaadin Ltd
*
* <p>
* This program is available under Vaadin Commercial License and Service Terms.
*
* <p>
* See <https://vaadin.com/commercial-license-and-service-terms> for the full
* license.
*/
Expand Down Expand Up @@ -45,14 +45,14 @@ public class VaadinConfigurationProperties {
private Pnpm pnpm = new Pnpm();

/**
* Custom package blacklist that should be skipped in scanning.
* List of blocked packages that shouldn't be scanned.
*/
private List<String> blacklistedPackages = new ArrayList<>();
private List<String> blockedPackages = new ArrayList<>();

/**
* Custom package whitelist that should be scanned.
* List of allowed packages that should be scanned.
*/
private List<String> whitelistedPackages = new ArrayList<>();
private List<String> allowedPackages = new ArrayList<>();

/**
* Whether a browser should be launched on startup when in development mode.
Expand Down Expand Up @@ -144,7 +144,7 @@ public boolean isLoadOnStartup() {
* server might be incorrectly handled by
* {@link com.vaadin.flow.spring.security.VaadinWebSecurityConfigurerAdapter}
* and access to a public view will be denied instead of allowed.
*
*
* @param loadOnStartup
* {@code true} to load the servlet on startup, {@code false}
* otherwise
Expand All @@ -168,7 +168,7 @@ public boolean isLaunchBrowser() {
/**
* Sets whether a browser should be launched on startup when in development
* mode.
*
*
* @param launchBrowser
* {@code true} to launch a browser on startup when in
* development mode, {@code false} otherwise
Expand Down Expand Up @@ -199,41 +199,84 @@ public void setPnpmEnabled(boolean enabled) {
}

/**
* Get a list of packages that are blacklisted for class scanning.
* Get a list of packages that are blocked for class scanning.
*
* @return package blacklist
* @return blocked packages
* @deprecated use getBlockedPackages()
*/
@Deprecated
public List<String> getBlacklistedPackages() {
return Collections.unmodifiableList(blacklistedPackages);
return Collections.unmodifiableList(blockedPackages);
}

/**
* Get a list of packages that are blocked for class scanning.
*
* @return blocked packages
*/
public List<String> getBlockedPackages() {
return Collections.unmodifiableList(blockedPackages);
}

/**
* Set a list of packages to ignore for class scanning.
*
* @param blockedPackages list of packages to ignore
* @deprecated use setBlockedPackages()
*/
@Deprecated
public void setBlacklistedPackages(List<String> blockedPackages) {
this.blockedPackages = new ArrayList<>(blockedPackages);
}

/**
* Set list of packages to ignore for class scanning.
* Set a list of packages to ignore for class scanning.
*
* @param blacklistedPackages
* list of packages to ignore
* @param blockedPackages list of packages to ignore
*/
public void setBlacklistedPackages(List<String> blacklistedPackages) {
this.blacklistedPackages = new ArrayList<>(blacklistedPackages);
public void setBlockedPackages(List<String> blockedPackages) {
this.blockedPackages = new ArrayList<>(blockedPackages);
}

/**
* Get a list of packages that are white-listed for class scanning.
* Get a list of packages that are allowed for class scanning.
*
* @return package white-list
* @return allowed packages
* @deprecated use getAllowedPackages()
*/
@Deprecated
public List<String> getWhitelistedPackages() {
return Collections.unmodifiableList(whitelistedPackages);
return Collections.unmodifiableList(allowedPackages);
}

/**
* Get a list of packages that are allowed for class scanning.
*
* @return allowed packages
*/
public List<String> getAllowedPackages() {
return Collections.unmodifiableList(allowedPackages);
}

/**
* Set list of packages to be scanned. If <code>allowedPackages</code>
* is set then <code>blockedPackages</code> is ignored.
*
* @param allowedPackages list of packages to be scanned
* @deprecated use setAllowedPackages()
*/
@Deprecated
public void setWhitelistedPackages(List<String> allowedPackages) {
this.allowedPackages = new ArrayList<>(allowedPackages);
}

/**
* Set list of packages to be scanned. If <code>whitelistedPackages</code>
* is set then <code>blacklistedPackages</code> is ignored.
* Set list of packages to be scanned. If <code>allowedPackages</code>
* is set then <code>blockedPackages</code> is ignored.
*
* @param whitelistedPackages
* list of packages to be scanned
* @param allowedPackages list of packages to be scanned
*/
public void setWhitelistedPackages(List<String> whitelistedPackages) {
this.whitelistedPackages = new ArrayList<>(whitelistedPackages);
public void setAllowedPackages(List<String> allowedPackages) {
this.allowedPackages = new ArrayList<>(allowedPackages);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,12 @@ public void failFastContextInitialized(ServletContextEvent event)
ms);

if (ms > 10000 && appContext.getEnvironment()
.getProperty("vaadin.whitelisted-packages") == null) {
.getProperty("vaadin.allowed-packages") == null
&& appContext.getEnvironment()
.getProperty("vaadin.whitelisted-packages") == null) {
getLogger().info(
"Due to slow search it is recommended to use the whitelisted-packages feature to make scanning faster.\n\n"
+ "See the whitelisted-packages section in the docs at https://vaadin.com/docs/latest/flow/integrations/spring/configuration#special-configuration-parameters");
"Class scanning is taking a long time. You can use the allowed-packages property to make it faster.\n\n"
+ "See documentation for details: https://vaadin.com/docs/integrations/spring/configuration");
}

try {
Expand Down Expand Up @@ -558,7 +560,14 @@ public void failFastContextInitialized(ServletContextEvent event) {
public VaadinServletContextInitializer(ApplicationContext context) {
appContext = context;
String neverScanProperty = appContext.getEnvironment()
.getProperty("vaadin.blacklisted-packages");
.getProperty("vaadin.blocked-packages");
if (neverScanProperty == null) {
neverScanProperty = appContext.getEnvironment()
.getProperty("vaadin.blacklisted-packages");
if (neverScanProperty != null) {
getLogger().warn("vaadin.blacklisted-packages is deprecated and may not be supported in the future. Use vaadin.blocked-packages instead.");
}
}
List<String> neverScan;
if (neverScanProperty == null) {
neverScan = Collections.emptyList();
Expand All @@ -569,7 +578,14 @@ public VaadinServletContextInitializer(ApplicationContext context) {
}

String onlyScanProperty = appContext.getEnvironment()
.getProperty("vaadin.whitelisted-packages");
.getProperty("vaadin.allowed-packages");
if (onlyScanProperty == null) {
onlyScanProperty = appContext.getEnvironment()
.getProperty("vaadin.whitelisted-packages");
if (onlyScanProperty != null) {
getLogger().warn("vaadin.whitelisted-packages is deprecated and may not be supported in the future. Use vaadin.allowed-packages instead.");
}
}
if (onlyScanProperty == null) {
customScanOnly = Collections.emptyList();
customLoader = new CustomResourceLoader(appContext, neverScan);
Expand All @@ -583,7 +599,7 @@ public VaadinServletContextInitializer(ApplicationContext context) {

if (!customScanOnly.isEmpty() && !neverScan.isEmpty()) {
getLogger().warn(
"vaadin.blacklisted-packages is ignored because both vaadin.whitelisted-packages and vaadin.blacklisted-packages have been set.");
"vaadin.blocked-packages is ignored because both vaadin.allowed-packages and vaadin.blocked-packages have been set.");
}
}

Expand Down