Skip to content

Commit

Permalink
remove commons-lang dependency, use and simplify Util.isBlank(String)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Bischof <[email protected]>
  • Loading branch information
stbischof committed Dec 2, 2021
1 parent b9f0309 commit 4e539d2
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 28 deletions.
5 changes: 0 additions & 5 deletions mondrian/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
<artifactId>commons-dbcp</artifactId>
<version>${commons-dbcp.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down
10 changes: 4 additions & 6 deletions mondrian/src/it/java/mondrian/rolap/RolapConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
import mondrian.olap.Util;
import mondrian.spi.Dialect;
import mondrian.test.TestContext;
import mondrian.util.Pair;

import junit.framework.TestCase;

import org.apache.commons.lang.StringUtils;

import java.sql.Connection;
import java.sql.SQLException;
Expand Down Expand Up @@ -493,7 +491,7 @@ public void testGetJdbcConnectionWhenJdbcIsNull() {
} catch (RuntimeException ex) {
assertTrue(
connectInfo.toString(),
StringUtils.isBlank(connectInfo.toString()));
Util.isBlank(connectInfo.toString()));
}
}

Expand All @@ -511,7 +509,7 @@ public void testJdbcConnectionString() {
DataSource dataSource =
RolapConnection.createDataSource(null, properties, connectInfo);

assertFalse(StringUtils.isBlank(connectInfo.toString()));
assertFalse(Util.isBlank(connectInfo.toString()));

String[] parseconnectInfo = connectInfo.toString().split(";");
for (String parseconnectInfoVals : parseconnectInfo) {
Expand All @@ -535,7 +533,7 @@ public void testJdbcConnectionStringWithoutDatabase() {
DataSource dataSource =
RolapConnection.createDataSource(null, properties, connectInfo);

assertFalse(StringUtils.isBlank(connectInfo.toString()));
assertFalse(Utils.isBlank(connectInfo.toString()));
assertFalse(connectInfo.toString().contains("databaseName"));
}

Expand All @@ -549,7 +547,7 @@ public void testJdbcConnectionStringWithoutIntegratedSecurity() {
DataSource dataSource =
RolapConnection.createDataSource(null, properties, connectInfo);

assertFalse(StringUtils.isBlank(connectInfo.toString()));
assertFalse(Utils.isBlank(connectInfo.toString()));
assertFalse(connectInfo.toString().contains("integratedSecurity"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import mondrian.spi.Dialect;
import mondrian.spi.DialectManager;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.*;

import java.io.*;
Expand Down Expand Up @@ -352,7 +351,7 @@ public static void main(String[] args) {
* populating tables and creating indexes
*/
private void load() throws Exception {
if (!StringUtils.isBlank(jdbcDrivers)) {
if (!Util.isBlank(jdbcDrivers)) {
RolapUtil.loadDrivers(jdbcDrivers);
}

Expand Down
11 changes: 1 addition & 10 deletions mondrian/src/main/java/mondrian/olap/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -3883,16 +3883,7 @@ public static String convertOlap4jConnectStringToNativeMondrian(
* @return <code>true</code> if the String is null, empty or whitespace
*/
public static boolean isBlank(String str) {
final int strLen;
if (str == null || (strLen = str.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(str.charAt(i))) {
return false;
}
}
return true;
return str == null || str.isBlank();
}

/**
Expand Down
5 changes: 2 additions & 3 deletions mondrian/src/main/java/mondrian/rolap/RolapConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import mondrian.spi.impl.JndiDataSourceResolver;
import mondrian.util.*;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

import org.eigenbase.util.property.StringProperty;
Expand Down Expand Up @@ -1136,11 +1135,11 @@ private static String getJdbcConnectionString( Util.PropertyList connectInfo ) {

String jdbc = connectInfo.get( RolapConnectionProperties.Jdbc.name() );

if ( StringUtils.isBlank( jdbc ) ) {
if ( Util.isBlank( jdbc ) ) {
return null;
}

String database = StringUtils.isBlank( connectInfo.get( "databaseName" ) )
String database = Util.isBlank( connectInfo.get( "databaseName" ) )
? "" : ";databaseName=" + connectInfo.get( "databaseName" );
String integratedSecurity = Boolean.parseBoolean( connectInfo.get( "integratedSecurity" ) )
? ";integratedSecurity=true" : "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import mondrian.rolap.*;
import mondrian.rolap.sql.SqlQuery;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

import java.util.*;
Expand Down
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<olap4j-xmlaserver.version>1.2.0</olap4j-xmlaserver.version>
<eigenbase-xom.version>1.3.5</eigenbase-xom.version>
<servlet-api.version>2.4</servlet-api.version>
<commons-lang.version>2.4</commons-lang.version>
<xmlunit.version>1.1</xmlunit.version>
</properties>
<profiles>
Expand Down

0 comments on commit 4e539d2

Please sign in to comment.