Skip to content

Commit f93e645

Browse files
committed
Set Java 11 as source+target version
As Hono has problems building on Java 8, and we already ship Java 11 images, we decided to fully switch to Java 11. But keeping the classpath model. This PR switches to Java 11 for source+target, and also makes use of a few Java 11-only features, just test it.
1 parent 9c48973 commit f93e645

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ sudo: required
33
language: java
44

55
jdk:
6-
# - openjdk8
76
- openjdk11
87

98
script:

adapters/coap-vertx/src/main/java/org/eclipse/hono/adapter/coap/vertx/VertxBasedCoapAdapter.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected String getTypeName() {
5858
public void getExtendedDevice(final CoapExchange exchange, final Handler<ExtendedDevice> handler) {
5959
try {
6060
final List<String> pathList = exchange.getRequestOptions().getUriPath();
61-
final String[] path = pathList.toArray(new String[pathList.size()]);
61+
final String[] path = pathList.toArray(String[]::new);
6262
final ResourceIdentifier identifier = ResourceIdentifier.fromPath(path);
6363
final Device device = new Device(identifier.getTenantId(), identifier.getResourceId());
6464
final Principal peer = exchange.advanced().getRequest().getSourceContext().getPeerIdentity();
@@ -69,9 +69,9 @@ public void getExtendedDevice(final CoapExchange exchange, final Handler<Extende
6969
} else {
7070
getAuthenticatedExtendedDevice(device, exchange, handler);
7171
}
72-
} catch (NullPointerException cause) {
72+
} catch (final NullPointerException cause) {
7373
CoapErrorResponse.respond(exchange, "missing tenant and device!", ResponseCode.BAD_REQUEST);
74-
} catch (Throwable cause) {
74+
} catch (final Throwable cause) {
7575
CoapErrorResponse.respond(exchange, cause, ResponseCode.INTERNAL_SERVER_ERROR);
7676
}
7777
}

core/src/main/java/org/eclipse/hono/util/AuthenticationConstants.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public static String[] parseSaslResponse(final byte[] saslResponse) throws Crede
162162
} else if (fields.get(2) == null || fields.get(2).length() == 0) {
163163
throw new CredentialException("PLAIN response must contain a password");
164164
} else {
165-
return fields.toArray(new String[3]);
165+
return fields.toArray(String[]::new);
166166
}
167167
}
168168
}

core/src/main/java/org/eclipse/hono/util/Hostnames.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public final class Hostnames {
2424
static {
2525

2626
// works on Linux
27-
String hostname = System.getenv("HOSTNAME");
27+
var hostname = System.getenv("HOSTNAME");
2828

2929
if (hostname == null) {
3030
// this can produce all kinds of unexpected results
3131
// but better than nothing
3232
try {
33-
final InetAddress localhost = InetAddress.getLocalHost();
33+
final var localhost = InetAddress.getLocalHost();
3434
hostname = localhost.getHostAddress();
3535
} catch (final Exception e) {
3636
}

core/src/main/java/org/eclipse/hono/util/ResourceIdentifier.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private ResourceIdentifier(final String resource, final boolean assumeDefaultTen
6060
if (assumeDefaultTenant) {
6161
pathSegments.add(1, Constants.DEFAULT_TENANT);
6262
}
63-
setResourcePath(pathSegments.toArray(new String[pathSegments.size()]));
63+
setResourcePath(pathSegments.toArray(String[]::new));
6464
}
6565

6666
private ResourceIdentifier(final String endpoint, final String tenantId, final String resourceId) {
@@ -94,7 +94,7 @@ private void setResourcePath(final String[] path) {
9494
pathSegments.add(segment);
9595
}
9696
}
97-
this.resourcePath = pathSegments.toArray(new String[pathSegments.size()]);
97+
this.resourcePath = pathSegments.toArray(String[]::new);
9898
if (resourcePath.length > IDX_TENANT_ID && resourcePath[IDX_TENANT_ID].length() == 0) {
9999
resourcePath[IDX_TENANT_ID] = null;
100100
}

pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@
236236
<plugin>
237237
<groupId>org.apache.maven.plugins</groupId>
238238
<artifactId>maven-compiler-plugin</artifactId>
239-
<version>3.7.0</version>
239+
<version>3.8.0</version>
240240
<configuration>
241-
<source>1.8</source>
242-
<target>1.8</target>
241+
<source>11</source>
242+
<target>11</target>
243243
<encoding>UTF-8</encoding>
244244
</configuration>
245245
</plugin>

services/auth/src/main/java/org/eclipse/hono/service/auth/impl/FileBasedAuthenticationService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private Authorities toAuthorities(final JsonArray authorities) {
196196
activityList.add(act);
197197
}
198198
});
199-
result.addResource(resource, activityList.toArray(new Activity[activityList.size()]));
199+
result.addResource(resource, activityList.toArray(Activity[]::new));
200200
} else if (operation != null) {
201201
final String[] parts = operation.split(":", 2);
202202
if (parts.length == 2) {

services/auth/src/main/java/org/eclipse/hono/service/auth/impl/SimpleAuthenticationServer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private int[] parseVersionString(final String version) {
177177
default:
178178
// return 0.0.0
179179
}
180-
} catch (NumberFormatException e) {
180+
} catch (final NumberFormatException e) {
181181
// return 0.0.0
182182
}
183183
return result;
@@ -204,7 +204,7 @@ private String[] getAuthorities(final String activities) {
204204
return null;
205205
}
206206
}).filter(Objects::nonNull).collect(Collectors.toSet());
207-
return result.toArray(new String[result.size()]);
207+
return result.toArray(String[]::new);
208208
}
209209

210210
@Override

0 commit comments

Comments
 (0)