Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge changes into beta #1907

Merged
merged 4 commits into from
Oct 23, 2024
Merged
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
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
},
"java.configuration.updateBuildConfiguration": "automatic",
// LSP was ooming and it recommended this change
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable",
// (jar) added -Xss8m so lombok would run without stack overflowing
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable -Xss8m",
"java.test.config": {
"vmargs": [ "-Dstripe.disallowGlobalResponseGetterFallback=true"]

}
},
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
* Remove support for `from_schedule` on `Quote.subscription_data`
* Add support for `allow_redisplay` on `terminal.ReaderCollectPaymentMethodParams.collect_config`

## 27.1.1 - 2024-10-18
* [#1901](https://github.com/stripe/stripe-java/pull/1901) update object tags for meter-related classes

- fixes a bug where the `object` property of the `MeterEvent`, `MeterEventAdjustment`, and `MeterEventSession` didn't match the server.
* [#1898](https://github.com/stripe/stripe-java/pull/1898) Clean up examples
* [#1894](https://github.com/stripe/stripe-java/pull/1894) Fixed example for raw request in readme file

## 27.1.0 - 2024-10-03
* [#1890](https://github.com/stripe/stripe-java/pull/1890) Update the class for `ThinEvent` to include `livemode` and `reason`
* [#1891](https://github.com/stripe/stripe-java/pull/1891) Removed the class `RequestSigningAuthenticator` that was added in the previous release. Request Signing is not supported yet.
Expand Down
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,23 @@ jacoco
// test code instrumentation for Java 18
toolVersion = "0.8.8"
}


// Used when developing in vscode-java; some of our examples use
// com.sun.net.httpserver. This is safe to do because the JDK
// team has committed to ensuring jdk.httpserver is exported.
// See https://openjdk.org/jeps/403, "Exported com.sun APIs"
import org.gradle.plugins.ide.eclipse.model.AccessRule

apply plugin: 'eclipse'

eclipse {
classpath {
file {
whenMerged {
def jre = entries.find { it.path.contains 'org.eclipse.jdt.launching.JRE_CONTAINER' }
jre.accessRules.add(new AccessRule('0', 'com/sun/net/httpserver/**'))
}
}
}
}
20 changes: 19 additions & 1 deletion src/main/java/com/stripe/model/EventDataObjectDeserializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,25 @@ private boolean apiVersionMatch() {
// Trim the locally configured API version to not include beta headers, since the payload won't
// have any.
String localApiVersion = StringUtils.trimApiVersion(Stripe.stripeVersion);
return localApiVersion.equals(StringUtils.trimApiVersion(this.apiVersion));
String eventApiVersion = StringUtils.trimApiVersion(this.apiVersion);

// Preserved for testing; we have tests that hook getIntegrationApiVersion
// to test with other api versions.
if (!localApiVersion.contains(".")) {
return eventApiVersion.equals(localApiVersion);
}

// If the event api version is from before we started adding
// a major release identifier, there's no way its compatible with this
// version
if (!eventApiVersion.contains(".")) {
return false;
}

// versions are yyyy-MM-dd.releaseIdentifier
String eventReleaseTrain = eventApiVersion.split("\\.", 2)[1];
String currentReleaseTrain = localApiVersion.split("\\.", 2)[1];
return eventReleaseTrain.equals(currentReleaseTrain);
}

/**
Expand Down
29 changes: 28 additions & 1 deletion src/test/java/com/stripe/functional/EventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,20 @@ public void testGetDataObjectWithSameApiVersion() throws StripeException {
}

@Test
public void testGetDataObjectWithDifferentApiVersion() throws StripeException {
public void testGetDataObjectWithNewApiVersionInSameReleaseTrain() throws StripeException {
String expectedReleaseTrain = Stripe.API_VERSION.split("\\.")[1];
final Event event = Event.retrieve(EVENT_ID);
// Suppose event has a different API version within the same release train as the
// library's pinned version
event.setApiVersion("2999-10-10." + expectedReleaseTrain);

Optional<StripeObject> stripeObject = event.getDataObjectDeserializer().getObject();

assertTrue(stripeObject.isPresent());
}

@Test
public void testGetDataObjectWithLegacyApiVersion() throws StripeException {
final Event event = Event.retrieve(EVENT_ID);
// Suppose event has different API version from the library's pinned version
event.setApiVersion("2017-05-25");
Expand All @@ -79,4 +92,18 @@ public void testGetDataObjectWithDifferentApiVersion() throws StripeException {
// handling schema incompatibility
assertFalse(stripeObject.isPresent());
}

@Test
public void testGetDataObjectWithReleaseTrainMismatch() throws StripeException {
final Event event = Event.retrieve(EVENT_ID);
// Suppose event has different API version and different release train from
// the libraries pinned version
event.setApiVersion("2999-10-10.the_larch");

Optional<StripeObject> stripeObject = event.getDataObjectDeserializer().getObject();

// See compatibility helper in `EventDataObjectDeserializerTest` for
// handling schema incompatibility
assertFalse(stripeObject.isPresent());
}
}
Loading