Skip to content

Commit

Permalink
Remove runtime dependency on maven-artifact
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ryanrupp committed Nov 22, 2024
1 parent ec2826c commit 8b2d3de
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
5 changes: 0 additions & 5 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@
<artifactId>java-jwt</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.9.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
21 changes: 6 additions & 15 deletions api/src/main/java/com/messagebird/MessageBirdServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.messagebird.exceptions.UnauthorizedException;
import com.messagebird.objects.ErrorReport;
import com.messagebird.objects.PagedPaging;
import org.apache.maven.artifact.versioning.ComparableVersion;

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

private static final ComparableVersion JAVA_VERSION = getJavaVersion();
private static final String JAVA_VERSION = getJavaVersion();

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

}

private static ComparableVersion getJavaVersion() {
try {
String version = System.getProperty("java.version");
return new ComparableVersion(version);
} catch (IllegalArgumentException e) {
return new ComparableVersion("0.0");
}
private static String getJavaVersion() {
String version = System.getProperty("java.version");
return version != null ? version : "0.0";
}

private String determineUserAgentString() {
Expand Down Expand Up @@ -637,11 +632,7 @@ private void setAdditionalHeaders(HttpURLConnection connection, Map<String, Stri
}

private DateFormat getDateFormat() {
ComparableVersion java6 = new ComparableVersion("1.6");
if (JAVA_VERSION.compareTo(java6) > 0) {
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
}
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZ");
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
}

/**
Expand Down Expand Up @@ -798,4 +789,4 @@ private String getPathVariables(final Map<String, Object> map) {
}
return bpath.toString();
}
}
}
12 changes: 12 additions & 0 deletions api/src/main/java/com/messagebird/common/StringUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.messagebird.common;

public class StringUtils {

private StringUtils() {
// static utility
}

public static boolean isBlank(String text) {
return text == null || text.trim().isEmpty();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.messagebird.objects.conversations;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;
import com.messagebird.common.StringUtils;

public class MessageParam {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.messagebird.objects.integrations;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;
import com.messagebird.common.StringUtils;

import java.util.List;

Expand Down

0 comments on commit 8b2d3de

Please sign in to comment.