Skip to content

Commit 602e99a

Browse files
mcollovatijouni
andauthored
fix: replace 'blacklist' and 'whitelist' with 'blocked' and 'allowed' (#1077) (#1080)
Co-authored-by: Jouni Koivuviita <[email protected]>
1 parent 3313a4f commit 602e99a

File tree

3 files changed

+91
-32
lines changed

3 files changed

+91
-32
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
server.port=8888
2-
vaadin.blacklisted-packages=vaadin-spring/target/test-classes
2+
vaadin.blocked-packages=vaadin-spring/target/test-classes

vaadin-spring/src/main/java/com/vaadin/flow/spring/VaadinConfigurationProperties.java

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Copyright (C) 2000-2023 Vaadin Ltd
3-
*
3+
* <p>
44
* This program is available under Vaadin Commercial License and Service Terms.
5-
*
5+
* <p>
66
* See <https://vaadin.com/commercial-license-and-service-terms> for the full
77
* license.
88
*/
@@ -45,14 +45,14 @@ public class VaadinConfigurationProperties {
4545
private Pnpm pnpm = new Pnpm();
4646

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

5252
/**
53-
* Custom package whitelist that should be scanned.
53+
* List of allowed packages that should be scanned.
5454
*/
55-
private List<String> whitelistedPackages = new ArrayList<>();
55+
private List<String> allowedPackages = new ArrayList<>();
5656

5757
/**
5858
* Whether a browser should be launched on startup when in development mode.
@@ -144,7 +144,7 @@ public boolean isLoadOnStartup() {
144144
* server might be incorrectly handled by
145145
* {@link com.vaadin.flow.spring.security.VaadinWebSecurityConfigurerAdapter}
146146
* and access to a public view will be denied instead of allowed.
147-
*
147+
*
148148
* @param loadOnStartup
149149
* {@code true} to load the servlet on startup, {@code false}
150150
* otherwise
@@ -168,7 +168,7 @@ public boolean isLaunchBrowser() {
168168
/**
169169
* Sets whether a browser should be launched on startup when in development
170170
* mode.
171-
*
171+
*
172172
* @param launchBrowser
173173
* {@code true} to launch a browser on startup when in
174174
* development mode, {@code false} otherwise
@@ -199,41 +199,84 @@ public void setPnpmEnabled(boolean enabled) {
199199
}
200200

201201
/**
202-
* Get a list of packages that are blacklisted for class scanning.
202+
* Get a list of packages that are blocked for class scanning.
203203
*
204-
* @return package blacklist
204+
* @return blocked packages
205+
* @deprecated use getBlockedPackages()
205206
*/
207+
@Deprecated
206208
public List<String> getBlacklistedPackages() {
207-
return Collections.unmodifiableList(blacklistedPackages);
209+
return Collections.unmodifiableList(blockedPackages);
210+
}
211+
212+
/**
213+
* Get a list of packages that are blocked for class scanning.
214+
*
215+
* @return blocked packages
216+
*/
217+
public List<String> getBlockedPackages() {
218+
return Collections.unmodifiableList(blockedPackages);
219+
}
220+
221+
/**
222+
* Set a list of packages to ignore for class scanning.
223+
*
224+
* @param blockedPackages list of packages to ignore
225+
* @deprecated use setBlockedPackages()
226+
*/
227+
@Deprecated
228+
public void setBlacklistedPackages(List<String> blockedPackages) {
229+
this.blockedPackages = new ArrayList<>(blockedPackages);
208230
}
209231

210232
/**
211-
* Set list of packages to ignore for class scanning.
233+
* Set a list of packages to ignore for class scanning.
212234
*
213-
* @param blacklistedPackages
214-
* list of packages to ignore
235+
* @param blockedPackages list of packages to ignore
215236
*/
216-
public void setBlacklistedPackages(List<String> blacklistedPackages) {
217-
this.blacklistedPackages = new ArrayList<>(blacklistedPackages);
237+
public void setBlockedPackages(List<String> blockedPackages) {
238+
this.blockedPackages = new ArrayList<>(blockedPackages);
218239
}
219240

220241
/**
221-
* Get a list of packages that are white-listed for class scanning.
242+
* Get a list of packages that are allowed for class scanning.
222243
*
223-
* @return package white-list
244+
* @return allowed packages
245+
* @deprecated use getAllowedPackages()
224246
*/
247+
@Deprecated
225248
public List<String> getWhitelistedPackages() {
226-
return Collections.unmodifiableList(whitelistedPackages);
249+
return Collections.unmodifiableList(allowedPackages);
250+
}
251+
252+
/**
253+
* Get a list of packages that are allowed for class scanning.
254+
*
255+
* @return allowed packages
256+
*/
257+
public List<String> getAllowedPackages() {
258+
return Collections.unmodifiableList(allowedPackages);
259+
}
260+
261+
/**
262+
* Set list of packages to be scanned. If <code>allowedPackages</code>
263+
* is set then <code>blockedPackages</code> is ignored.
264+
*
265+
* @param allowedPackages list of packages to be scanned
266+
* @deprecated use setAllowedPackages()
267+
*/
268+
@Deprecated
269+
public void setWhitelistedPackages(List<String> allowedPackages) {
270+
this.allowedPackages = new ArrayList<>(allowedPackages);
227271
}
228272

229273
/**
230-
* Set list of packages to be scanned. If <code>whitelistedPackages</code>
231-
* is set then <code>blacklistedPackages</code> is ignored.
274+
* Set list of packages to be scanned. If <code>allowedPackages</code>
275+
* is set then <code>blockedPackages</code> is ignored.
232276
*
233-
* @param whitelistedPackages
234-
* list of packages to be scanned
277+
* @param allowedPackages list of packages to be scanned
235278
*/
236-
public void setWhitelistedPackages(List<String> whitelistedPackages) {
237-
this.whitelistedPackages = new ArrayList<>(whitelistedPackages);
279+
public void setAllowedPackages(List<String> allowedPackages) {
280+
this.allowedPackages = new ArrayList<>(allowedPackages);
238281
}
239282
}

vaadin-spring/src/main/java/com/vaadin/flow/spring/VaadinServletContextInitializer.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,12 @@ public void failFastContextInitialized(ServletContextEvent event)
453453
ms);
454454

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

462464
try {
@@ -558,7 +560,14 @@ public void failFastContextInitialized(ServletContextEvent event) {
558560
public VaadinServletContextInitializer(ApplicationContext context) {
559561
appContext = context;
560562
String neverScanProperty = appContext.getEnvironment()
561-
.getProperty("vaadin.blacklisted-packages");
563+
.getProperty("vaadin.blocked-packages");
564+
if (neverScanProperty == null) {
565+
neverScanProperty = appContext.getEnvironment()
566+
.getProperty("vaadin.blacklisted-packages");
567+
if (neverScanProperty != null) {
568+
getLogger().warn("vaadin.blacklisted-packages is deprecated and may not be supported in the future. Use vaadin.blocked-packages instead.");
569+
}
570+
}
562571
List<String> neverScan;
563572
if (neverScanProperty == null) {
564573
neverScan = Collections.emptyList();
@@ -569,7 +578,14 @@ public VaadinServletContextInitializer(ApplicationContext context) {
569578
}
570579

571580
String onlyScanProperty = appContext.getEnvironment()
572-
.getProperty("vaadin.whitelisted-packages");
581+
.getProperty("vaadin.allowed-packages");
582+
if (onlyScanProperty == null) {
583+
onlyScanProperty = appContext.getEnvironment()
584+
.getProperty("vaadin.whitelisted-packages");
585+
if (onlyScanProperty != null) {
586+
getLogger().warn("vaadin.whitelisted-packages is deprecated and may not be supported in the future. Use vaadin.allowed-packages instead.");
587+
}
588+
}
573589
if (onlyScanProperty == null) {
574590
customScanOnly = Collections.emptyList();
575591
customLoader = new CustomResourceLoader(appContext, neverScan);
@@ -583,7 +599,7 @@ public VaadinServletContextInitializer(ApplicationContext context) {
583599

584600
if (!customScanOnly.isEmpty() && !neverScan.isEmpty()) {
585601
getLogger().warn(
586-
"vaadin.blacklisted-packages is ignored because both vaadin.whitelisted-packages and vaadin.blacklisted-packages have been set.");
602+
"vaadin.blocked-packages is ignored because both vaadin.allowed-packages and vaadin.blocked-packages have been set.");
587603
}
588604
}
589605

0 commit comments

Comments
 (0)