Skip to content

Commit 97dfaf7

Browse files
committed
task: Use getInputStream to get data
As reported in #377 - getContent() when building with GraalVM uses serviceloaders to locate the correct content processor. But we've already checked that we don't have a gzip stream, so we're trusting our upstream to return application/json and do not need a content processor. This saves us a cast from content to InputStream as well. fixes: #377
1 parent 01f1aa2 commit 97dfaf7

2 files changed

Lines changed: 43 additions & 23 deletions

File tree

pom.xml

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<project
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
6+
>
37
<modelVersion>4.0.0</modelVersion>
48
<groupId>io.getunleash</groupId>
59
<artifactId>unleash-client-java</artifactId>
6-
<version>12.2.2-SNAPSHOT-SNAPSHOT</version>
10+
<version>12.2.2-SNAPSHOT</version>
711

812
<properties>
913
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -53,8 +57,10 @@
5357

5458
<scm>
5559
<url>https://github.com/Unleash/unleash-java-sdk</url>
56-
<connection>scm:git:https://github.com/Unleash/unleash-java-sdk.git</connection>
57-
<developerConnection>scm:git:https://github.com/Unleash/unleash-java-sdk.git</developerConnection>
60+
<connection
61+
>scm:git:https://github.com/Unleash/unleash-java-sdk.git</connection>
62+
<developerConnection
63+
>scm:git:https://github.com/Unleash/unleash-java-sdk.git</developerConnection>
5864
</scm>
5965

6066
<dependencies>
@@ -188,7 +194,8 @@
188194
<version>3.5.2</version>
189195
<configuration>
190196
<forkCount>1</forkCount>
191-
<argLine>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
197+
<argLine
198+
>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
192199
</configuration>
193200
</plugin>
194201
<plugin>
@@ -198,8 +205,10 @@
198205
<configuration>
199206
<archive>
200207
<manifest>
201-
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
202-
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
208+
<addDefaultImplementationEntries
209+
>true</addDefaultImplementationEntries>
210+
<addDefaultSpecificationEntries
211+
>true</addDefaultSpecificationEntries>
203212
</manifest>
204213
</archive>
205214
</configuration>
@@ -235,9 +244,11 @@
235244
</goals>
236245
<configuration>
237246
<url>https://github.com</url>
238-
<fromFile>Unleash/client-specification/archive/v${version.unleash.specification}.zip
247+
<fromFile
248+
>Unleash/client-specification/archive/v${version.unleash.specification}.zip
239249
</fromFile>
240-
<toDir>${project.build.directory}/client-specification</toDir>
250+
<toDir
251+
>${project.build.directory}/client-specification</toDir>
241252
</configuration>
242253
</execution>
243254
</executions>
@@ -261,7 +272,8 @@
261272
<directory>
262273
${project.build.directory}/client-specification/v${version.unleash.specification}.zip
263274
</directory>
264-
<outputDirectory>${project.build.directory}/client-specification/</outputDirectory>
275+
<outputDirectory
276+
>${project.build.directory}/client-specification/</outputDirectory>
265277
</fileset>
266278
</configuration>
267279
</execution>
@@ -281,7 +293,8 @@
281293
<goal>copy-resources</goal>
282294
</goals>
283295
<configuration>
284-
<outputDirectory>${project.build.testOutputDirectory}/client-specification</outputDirectory>
296+
<outputDirectory
297+
>${project.build.testOutputDirectory}/client-specification</outputDirectory>
285298
<resources>
286299
<resource>
287300
<directory>
@@ -325,8 +338,10 @@
325338
<mavenCentral>
326339
<sonatype>
327340
<active>ALWAYS</active>
328-
<url>https://central.sonatype.com/api/v1/publisher</url>
329-
<stagingRepositories>target/staging-deploy</stagingRepositories>
341+
<url
342+
>https://central.sonatype.com/api/v1/publisher</url>
343+
<stagingRepositories
344+
>target/staging-deploy</stagingRepositories>
330345
<retryDelay>60</retryDelay>
331346
<maxRetries>40</maxRetries>
332347
</sonatype>
@@ -402,7 +417,8 @@
402417
<artifactId>maven-surefire-plugin</artifactId>
403418
<version>3.5.2</version>
404419
<configuration>
405-
<argLine>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
420+
<argLine
421+
>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
406422
</configuration>
407423
</plugin>
408424
</plugins>
@@ -414,13 +430,15 @@
414430
<activeByDefault>false</activeByDefault>
415431
</activation>
416432
<properties>
417-
<sonatypeOssDistMgmtSnapshotsUrl>https://s01.oss.sonatype.org/content/repositories/snapshots</sonatypeOssDistMgmtSnapshotsUrl>
433+
<sonatypeOssDistMgmtSnapshotsUrl
434+
>https://s01.oss.sonatype.org/content/repositories/snapshots</sonatypeOssDistMgmtSnapshotsUrl>
418435
</properties>
419436
<repositories>
420437
<repository>
421438
<id>sonatype-nexus-snapshots</id>
422439
<name>Sonatype Nexus Snapshots</name>
423-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
440+
<url
441+
>https://oss.sonatype.org/content/repositories/snapshots</url>
424442
<releases>
425443
<enabled>false</enabled>
426444
</releases>
@@ -438,7 +456,8 @@
438456
<repository>
439457
<id>sonatype-nexus-staging</id>
440458
<name>Nexus Release Repository</name>
441-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
459+
<url
460+
>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
442461
</repository>
443462
</distributionManagement>
444463
<build>
@@ -507,7 +526,8 @@
507526
<profile>
508527
<id>publication</id>
509528
<properties>
510-
<altDeploymentRepository>local::file:./target/staging-deploy</altDeploymentRepository>
529+
<altDeploymentRepository
530+
>local::file:./target/staging-deploy</altDeploymentRepository>
511531
</properties>
512532
<build>
513533
<defaultGoal>deploy</defaultGoal>
@@ -553,7 +573,8 @@
553573
<repository>
554574
<id>sonatype-nexus-staging</id>
555575
<name>Nexus Release Repository</name>
556-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
576+
<url
577+
>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
557578
</repository>
558579
</distributionManagement>
559580
</profile>

src/main/java/io/getunleash/repository/HttpFeatureFetcher.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.slf4j.LoggerFactory;
1717

1818
public class HttpFeatureFetcher implements FeatureFetcher {
19+
1920
private static final Logger LOG = LoggerFactory.getLogger(HttpFeatureFetcher.class);
2021
private Optional<String> etag = Optional.empty();
2122

@@ -74,9 +75,7 @@ private ClientFeaturesResponse getFeatureResponse(
7475
try (BufferedReader reader =
7576
new BufferedReader(
7677
new InputStreamReader(
77-
(InputStream) request.getContent(),
78-
StandardCharsets.UTF_8))) {
79-
78+
request.getInputStream(), StandardCharsets.UTF_8))) {
8079
String clientFeatures = reader.lines().collect(Collectors.joining("\n"));
8180

8281
return ClientFeaturesResponse.updated(clientFeatures);

0 commit comments

Comments
 (0)