Skip to content

Commit 8b2d3de

Browse files
committed
Remove runtime dependency on maven-artifact
This was primarily being used to check the Java version to handle < Java 7 in a different way for date formatting, but since Java 8 is the minimum version at this point it is no longer necessary. Also ends up removing the transitive dependency on commons lang which had minimal usage but replaced with an internal StringUtils equivalent.
1 parent ec2826c commit 8b2d3de

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

api/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@
9292
<artifactId>java-jwt</artifactId>
9393
<version>4.4.0</version>
9494
</dependency>
95-
<dependency>
96-
<groupId>org.apache.maven</groupId>
97-
<artifactId>maven-artifact</artifactId>
98-
<version>3.9.6</version>
99-
</dependency>
10095
<dependency>
10196
<groupId>junit</groupId>
10297
<artifactId>junit</artifactId>

api/src/main/java/com/messagebird/MessageBirdServiceImpl.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.messagebird.exceptions.UnauthorizedException;
99
import com.messagebird.objects.ErrorReport;
1010
import com.messagebird.objects.PagedPaging;
11-
import org.apache.maven.artifact.versioning.ComparableVersion;
1211

1312
import java.io.File;
1413
import java.io.FileOutputStream;
@@ -62,7 +61,7 @@ public class MessageBirdServiceImpl implements MessageBirdService {
6261
private static final String[] PROTOCOL_LISTS = new String[]{"http://", "https://"};
6362
private static final List<String> PROTOCOLS = Arrays.asList(PROTOCOL_LISTS);
6463

65-
private static final ComparableVersion JAVA_VERSION = getJavaVersion();
64+
private static final String JAVA_VERSION = getJavaVersion();
6665

6766
// Indicates whether we've overridden HttpURLConnection's behaviour to
6867
// allow PATCH requests yet. Also see docs on allowPatchRequestsIfNeeded().
@@ -89,13 +88,9 @@ public MessageBirdServiceImpl(final String accessKey, final String serviceUrl) {
8988

9089
}
9190

92-
private static ComparableVersion getJavaVersion() {
93-
try {
94-
String version = System.getProperty("java.version");
95-
return new ComparableVersion(version);
96-
} catch (IllegalArgumentException e) {
97-
return new ComparableVersion("0.0");
98-
}
91+
private static String getJavaVersion() {
92+
String version = System.getProperty("java.version");
93+
return version != null ? version : "0.0";
9994
}
10095

10196
private String determineUserAgentString() {
@@ -637,11 +632,7 @@ private void setAdditionalHeaders(HttpURLConnection connection, Map<String, Stri
637632
}
638633

639634
private DateFormat getDateFormat() {
640-
ComparableVersion java6 = new ComparableVersion("1.6");
641-
if (JAVA_VERSION.compareTo(java6) > 0) {
642-
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
643-
}
644-
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZ");
635+
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
645636
}
646637

647638
/**
@@ -798,4 +789,4 @@ private String getPathVariables(final Map<String, Object> map) {
798789
}
799790
return bpath.toString();
800791
}
801-
}
792+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.messagebird.common;
2+
3+
public class StringUtils {
4+
5+
private StringUtils() {
6+
// static utility
7+
}
8+
9+
public static boolean isBlank(String text) {
10+
return text == null || text.trim().isEmpty();
11+
}
12+
}

api/src/main/java/com/messagebird/objects/conversations/MessageParam.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.messagebird.objects.conversations;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
4-
import org.apache.commons.lang3.StringUtils;
4+
import com.messagebird.common.StringUtils;
55

66
public class MessageParam {
77

api/src/main/java/com/messagebird/objects/integrations/HSMComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.messagebird.objects.integrations;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
4-
import org.apache.commons.lang3.StringUtils;
4+
import com.messagebird.common.StringUtils;
55

66
import java.util.List;
77

0 commit comments

Comments
 (0)