Skip to content

Commit 017e444

Browse files
Remove deprecated code + some code format
1 parent 399115b commit 017e444

8 files changed

Lines changed: 25 additions & 21 deletions

File tree

jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Licensed to the Apache Software Foundation (ASF) under one
3636
import org.apache.wiki.auth.permissions.AllPermission;
3737
import org.apache.wiki.auth.permissions.PagePermission;
3838
import org.apache.wiki.auth.user.UserDatabase;
39-
import org.apache.wiki.auth.user.UserProfile;
4039
import org.apache.wiki.event.WikiEventListener;
4140
import org.apache.wiki.event.WikiEventManager;
4241
import org.apache.wiki.event.WikiSecurityEvent;

jspwiki-main/src/test/java/org/apache/wiki/TestJDBCDataSource.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ Licensed to the Apache Software Foundation (ASF) under one
2424
import java.io.PrintWriter;
2525
import java.net.URL;
2626
import java.net.URLClassLoader;
27-
import java.security.AccessController;
28-
import java.security.PrivilegedAction;
2927
import java.sql.Connection;
3028
import java.sql.Driver;
3129
import java.sql.SQLException;
@@ -63,7 +61,7 @@ public class TestJDBCDataSource implements DataSource
6361

6462
protected PrintWriter m_writer;
6563

66-
/**
64+
/**
6765
* Constructs a new instance of this class, using a supplied properties
6866
* File as the source for JDBC driver properties.
6967
* @param file the properties file containing JDBC properties
@@ -160,8 +158,8 @@ public void setLogWriter(final PrintWriter out ) throws SQLException
160158

161159
/**
162160
* Return the parent Logger of all the Loggers used by this data source. This should be
163-
* the Logger farthest from the root Logger that is still an ancestor of all of the Loggers used by this data source.
164-
* Configuring this Logger will affect all of the log messages generated by the data source. In the worst case, this
161+
* the Logger farthest from the root Logger that is still an ancestor of all the Loggers used by this data source.
162+
* Configuring this Logger will affect all the log messages generated by the data source. In the worst case, this
165163
* may be the root Logger.
166164
* @return the parent Logger for this data source
167165
*/
@@ -199,16 +197,16 @@ protected void initializeJDBC( final Properties properties) throws Exception {
199197
final String clazz = properties.getProperty( PROPERTY_DRIVER_CLASS );
200198
final String driverFile = properties.getProperty( PROPERTY_DRIVER_JAR );
201199

202-
// Construct an URL for loading the file
200+
// Construct a URL for loading the file
203201
final URL driverURL = new URL( "file:" + driverFile );
204202

205203
// Load the driver using the sytem class loader
206204
final ClassLoader parent = ClassLoader.getSystemClassLoader();
207-
final URLClassLoader loader = AccessController.doPrivileged( ( PrivilegedAction< URLClassLoader > ) () -> new URLClassLoader( new URL[] { driverURL }, parent ) );
205+
final URLClassLoader loader = new URLClassLoader( new URL[] { driverURL }, parent );
208206
final Class< ? > driverClass = loader.loadClass( clazz );
209207

210208
// Cache the driver
211-
m_driver = (Driver) driverClass.newInstance();
209+
m_driver = (Driver) driverClass.getDeclaredConstructor().newInstance();
212210
}
213211

214212
@Override

jspwiki-main/src/test/java/org/apache/wiki/auth/permissions/GroupPermissionTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ Licensed to the Apache Software Foundation (ASF) under one
1818
*/
1919
package org.apache.wiki.auth.permissions;
2020

21+
import org.apache.wiki.auth.GroupPrincipal;
22+
import org.apache.wiki.auth.WikiPrincipal;
23+
import org.junit.jupiter.api.Assertions;
24+
import org.junit.jupiter.api.Test;
25+
26+
import javax.security.auth.Subject;
2127
import java.security.AccessControlException;
2228
import java.security.Permission;
2329
import java.security.PrivilegedAction;

jspwiki-util/src/main/java/org/apache/wiki/util/ClassUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Licensed to the Apache Software Foundation (ASF) under one
2020

2121
import org.apache.commons.io.FileUtils;
2222
import org.apache.commons.lang3.StringUtils;
23+
import org.apache.commons.lang3.Strings;
2324
import org.apache.logging.log4j.LogManager;
2425
import org.apache.logging.log4j.Logger;
2526
import org.jdom2.Element;
@@ -224,7 +225,7 @@ static void fileEntriesUnder( final List< String > results, final File file, fin
224225
while( files.hasNext() ) {
225226
final File subfile = files.next();
226227
// store an entry similar to the jarSearch(..) below ones
227-
final String entry = StringUtils.replace( subfile.getAbsolutePath(), file.getAbsolutePath() + File.separatorChar, StringUtils.EMPTY );
228+
final String entry = Strings.CS.replace( subfile.getAbsolutePath(), file.getAbsolutePath() + File.separatorChar, StringUtils.EMPTY );
228229
results.add( rootPackage + "/" + entry );
229230
}
230231
} else {

jspwiki-util/src/main/java/org/apache/wiki/util/TextUtil.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Licensed to the Apache Software Foundation (ASF) under one
1818
*/
1919
package org.apache.wiki.util;
2020

21-
import org.apache.commons.lang3.StringUtils;
21+
import org.apache.commons.lang3.Strings;
2222
import org.apache.logging.log4j.LogManager;
2323
import org.apache.logging.log4j.Logger;
2424

@@ -339,7 +339,7 @@ public static int parseIntParameter( final String value, final int defvalue ) {
339339
* @return The property value as an integer (or defVal).
340340
*/
341341
public static int getIntegerProperty( final Properties props, final String key, final int defVal ) {
342-
String val = System.getProperties().getProperty( key, System.getenv( StringUtils.replace( key,".","_" ) ) );
342+
String val = System.getProperties().getProperty( key, System.getenv( Strings.CS.replace( key,".","_" ) ) );
343343
if( val == null ) {
344344
val = props.getProperty( key );
345345
}
@@ -364,7 +364,7 @@ public static int getIntegerProperty( final Properties props, final String key,
364364
* @since 2.0.11
365365
*/
366366
public static boolean getBooleanProperty( final Properties props, final String key, final boolean defval ) {
367-
String val = System.getProperties().getProperty( key, System.getenv( StringUtils.replace( key,".","_" ) ) );
367+
String val = System.getProperties().getProperty( key, System.getenv( Strings.CS.replace( key,".","_" ) ) );
368368
if( val == null ) {
369369
val = props.getProperty( key );
370370
}
@@ -390,7 +390,7 @@ public static boolean getBooleanProperty( final Properties props, final String k
390390
* @since 2.1.151
391391
*/
392392
public static String getStringProperty( final Properties props, final String key, final String defval ) {
393-
String val = System.getProperties().getProperty( key, System.getenv( StringUtils.replace( key,".","_" ) ) );
393+
String val = System.getProperties().getProperty( key, System.getenv( Strings.CS.replace( key,".","_" ) ) );
394394
if( val == null ) {
395395
val = props.getProperty( key );
396396
}
@@ -472,7 +472,7 @@ public static String getRequiredProperty( final Properties props, final String k
472472
* @since 2.10.1
473473
*/
474474
public static String getCanonicalFilePathProperty( final Properties props, final String key, final String defval ) {
475-
String val = System.getProperties().getProperty( key, System.getenv( StringUtils.replace( key,".","_" ) ) );
475+
String val = System.getProperties().getProperty( key, System.getenv( Strings.CS.replace( key,".","_" ) ) );
476476
if( val == null ) {
477477
val = props.getProperty( key );
478478
}

jspwiki-util/src/main/java/org/apache/wiki/util/comparators/CollatorComparator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Licensed to the Apache Software Foundation (ASF) under one
1919

2020
package org.apache.wiki.util.comparators;
2121

22-
import org.apache.commons.lang3.StringUtils;
22+
import org.apache.commons.lang3.Strings;
2323

2424
import java.text.Collator;
2525
import java.util.Comparator;
@@ -64,7 +64,7 @@ public CollatorComparator(final Collator collator )
6464
@Override
6565
public int compare(final String str1, final String str2 )
6666
{
67-
if( StringUtils.equals( str1, str2 ) ) {
67+
if( Strings.CS.equals( str1, str2 ) ) {
6868
return 0; // the same object
6969
}
7070
if( str1 == null ) {

jspwiki-util/src/main/java/org/apache/wiki/util/comparators/HumanComparator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Licensed to the Apache Software Foundation (ASF) under one
1919

2020
package org.apache.wiki.util.comparators;
2121

22-
import org.apache.commons.lang3.StringUtils;
22+
import org.apache.commons.lang3.Strings;
2323

2424
import java.util.Comparator;
2525

@@ -82,7 +82,7 @@ public HumanComparator(final CharType[] sortOrder )
8282
public int compare(final String str1, final String str2 )
8383
{
8484
// Some quick and easy checks
85-
if( StringUtils.equals( str1, str2 ) ) {
85+
if( Strings.CS.equals( str1, str2 ) ) {
8686
// they're identical, possibly both null
8787
return 0;
8888
} else if ( str1 == null ) {

jspwiki-util/src/main/java/org/apache/wiki/util/comparators/JavaNaturalComparator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Licensed to the Apache Software Foundation (ASF) under one
1919

2020
package org.apache.wiki.util.comparators;
2121

22-
import org.apache.commons.lang3.StringUtils;
22+
import org.apache.commons.lang3.Strings;
2323

2424
import java.util.Comparator;
2525

@@ -38,7 +38,7 @@ public class JavaNaturalComparator implements Comparator<String>
3838
*/
3939
@Override
4040
public int compare(final String str1, final String str2 ) {
41-
if (StringUtils.equals( str1, str2 ) ) {
41+
if( Strings.CS.equals( str1, str2 ) ) {
4242
return 0; // the same object
4343
}
4444
if( str1 == null ) {

0 commit comments

Comments
 (0)