Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"cliVersion": "4.29.0",
"cliVersion": "4.68.0",
"generatorName": "fernapi/fern-java-sdk",
"generatorVersion": "3.44.1",
"generatorVersion": "4.1.4",
"generatorConfig": {
"publish-to": "central"
},
"originGitCommit": "bbd2054c67ad246b017399f96faf58cf6737bf01",
"sdkVersion": "2.0.0"
"originGitCommit": "e6e039aeca5c5b1f34982fd1ca7d3ec3ae6e1a02",
"sdkVersion": "2.0.1"
}
1 change: 1 addition & 0 deletions .fernignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
LICENSE

# README.md
changelog.md
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Add the dependency in your `build.gradle` file:

```groovy
dependencies {
implementation 'com.newscatcherapi:newscatcher-sdk'
implementation 'com.newscatcherapi:newscatcher-sdk:2.0.1'
}
```

Expand All @@ -55,7 +55,7 @@ Add the dependency in your `pom.xml` file:
<dependency>
<groupId>com.newscatcherapi</groupId>
<artifactId>newscatcher-sdk</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</dependency>
```

Expand Down Expand Up @@ -334,7 +334,7 @@ The `withRawResponse()` method returns a raw client that wraps all responses wit
(A normal client's `response` is identical to a raw client's `response.body()`.)

```java
PostHttpResponse response = client.search().withRawResponse().post(...);
NewscatcherApiHttpResponse response = client.search().withRawResponse().post(...);

System.out.println(response.body());
System.out.println(response.headers().get("X-My-Header"));
Expand All @@ -353,3 +353,4 @@ On the other hand, contributions to the README are always very welcome!

For release notes and changelog, visit our [GitHub releases page](https://github.com/Newscatcher/newscatcher-java/releases).


4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ java {

group = 'com.newscatcherapi'

version = '2.0.0'
version = '2.0.1'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand Down Expand Up @@ -78,7 +78,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.newscatcherapi'
artifactId = 'newscatcher-sdk'
version = '2.0.0'
version = '2.0.1'
from components.java
pom {
name = 'newscatcher'
Expand Down
16 changes: 16 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## 2.0.1 - 2026-04-13
* fix: replace @JsonProperty with @JsonIgnore on request getter methods
* Request objects across multiple endpoints used @JsonProperty annotations
* on getter methods, which caused Jackson to inadvertently serialize request
* fields into the JSON body when these objects were used in contexts that
* triggered serialization. Replacing with @JsonIgnore ensures these request
* POJOs are not accidentally serialized as JSON bodies — parameters are
* instead passed as query/path parameters via the HTTP layer.
* Additionally, refactors RetryInterceptor to instantiate a fresh
* ExponentialBackoff per retry cycle rather than reusing a shared instance,
* preventing potential state leakage across concurrent or sequential requests.
* Key changes:
* Replace @JsonProperty with @JsonIgnore on all getter methods in GetAggregationCountRequest, GetAuthorsRequest, and GetBreakingNewsRequest
* Refactor RetryInterceptor to create a new ExponentialBackoff instance per retryChain() invocation instead of holding a shared instance
* 🌿 Generated with Fern

4 changes: 2 additions & 2 deletions src/main/java/com/newscatcher/api/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ private ClientOptions(
this.headers.putAll(headers);
this.headers.putAll(new HashMap<String, String>() {
{
put("User-Agent", "com.newscatcherapi:newscatcher-sdk/2.0.0");
put("User-Agent", "com.newscatcherapi:newscatcher-sdk/2.0.1");
put("X-Fern-Language", "JAVA");
put("X-Fern-SDK-Name", "com.newscatcher.fern:api-sdk");
put("X-Fern-SDK-Version", "2.0.0");
put("X-Fern-SDK-Version", "2.0.1");
}
});
this.headerSuppliers = headerSuppliers;
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/com/newscatcher/api/core/DoubleSerializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.newscatcher.api.core;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.module.SimpleModule;
import java.io.IOException;

/**
* Custom serializer that writes integer-valued doubles without a decimal point.
* For example, {@code 24000.0} is serialized as {@code 24000} instead of {@code 24000.0}.
* Non-integer values like {@code 3.14} are serialized normally.
*/
class DoubleSerializer extends JsonSerializer<Double> {
private static final SimpleModule MODULE;

static {
MODULE = new SimpleModule()
.addSerializer(Double.class, new DoubleSerializer())
.addSerializer(double.class, new DoubleSerializer());
}

/**
* Gets a module wrapping this serializer as an adapter for the Jackson ObjectMapper.
*
* @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper.
*/
public static SimpleModule getModule() {
return MODULE;
}

@Override
public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
if (value != null && value == Math.floor(value) && !Double.isInfinite(value) && !Double.isNaN(value)) {
gen.writeNumber(value.longValue());
} else {
gen.writeNumber(value);
}
}
}
1 change: 1 addition & 0 deletions src/main/java/com/newscatcher/api/core/ObjectMappers.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public final class ObjectMappers {
.addModule(new Jdk8Module())
.addModule(new JavaTimeModule())
.addModule(DateTimeDeserializer.getModule())
.addModule(DoubleSerializer.getModule())
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.build();
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/newscatcher/api/core/RetryInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public class RetryInterceptor implements Interceptor {
private static final Duration MAX_RETRY_DELAY = Duration.ofMillis(60000);
private static final double JITTER_FACTOR = 0.2;

private final ExponentialBackoff backoff;
private final int maxRetries;
private final Random random = new Random();

public RetryInterceptor(int maxRetries) {
this.backoff = new ExponentialBackoff(maxRetries);
this.maxRetries = maxRetries;
}

@Override
Expand All @@ -38,7 +38,8 @@ public Response intercept(Chain chain) throws IOException {
}

private Response retryChain(Response response, Chain chain) throws IOException {
Optional<Duration> nextBackoff = this.backoff.nextBackoff(response);
ExponentialBackoff backoff = new ExponentialBackoff(this.maxRetries);
Optional<Duration> nextBackoff = backoff.nextBackoff(response);
while (nextBackoff.isPresent()) {
try {
Thread.sleep(nextBackoff.get().toMillis());
Expand All @@ -48,7 +49,7 @@ private Response retryChain(Response response, Chain chain) throws IOException {
response.close();
response = chain.proceed(chain.request());
if (shouldRetry(response.code())) {
nextBackoff = this.backoff.nextBackoff(response);
nextBackoff = backoff.nextBackoff(response);
} else {
return response;
}
Expand Down
Loading
Loading