Skip to content

Conversation

@xavdid-stripe
Copy link
Member

Why?

The hosted docs were a little late merging, so I wanted to make sure they got linked in the changelog. Plus I added the fully-working example from the original PR to the actual code. I also took the opportunity to make sure the hosted docs matched these working examples.

What?

  • add new example
  • update changelog

See Also

@xavdid-stripe xavdid-stripe requested a review from a team as a code owner December 16, 2025 22:50
@xavdid-stripe xavdid-stripe requested review from prathmesh-stripe and removed request for a team December 16, 2025 22:50
@xavdid-stripe xavdid-stripe enabled auto-merge (squash) December 16, 2025 22:52
@xavdid-stripe xavdid-stripe merged commit a028ed8 into beta Dec 16, 2025
14 checks passed
@xavdid-stripe xavdid-stripe deleted the update-handler-docs branch December 16, 2025 23:45
Comment on lines +39 to +40
private static final StripeClient client = new StripeClient(API_KEY);
private static final StripeEventNotificationHandler handler =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: private static final variables are generally done in ALL_CAPS. I think private final would make more sense here anyway

Copy link
Member Author

@xavdid-stripe xavdid-stripe Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's fair! though, since we're calling it from public static void main, the compiler complains Cannot make a static reference to the non-static field. I think for the purposes of the example, it's fine as is.

Comment on lines +64 to +68
} catch (StripeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting. I hadn't thought about this before, but perhaps they want to throw here so their webhook handler can return a non-200 response. Can you throw a checked exception here, or does that no longer compile?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I played with that, but then Java complains that the handler.onV1BillingMeterErrorReportTriggered(EventNotificationHandlerEndpoint::handleMeterErrors); line generates an unhandled exception. That's a little odd, since it feels like that's just a function pointer and isn't calling the function, but i'm not sure.

Given that it's just an example, I think i'm fine with either:

  • leaving the example not-quite-complete and letting users figure out how they want to handle the error
  • eating the error and understanding that it's not a production-ready handler.

do you have strong feelings?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the thing with checked exceptions--they are considered part of the signature of the function. I think before we go to GA, we should see if we can make a checked StripeException part of the signature of the Callback.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but I'm not sure how we communicate to java that calling onV1BillingMeterErrorReportTriggered wont throw that checked exception, but calling .handle() could throw every exception that any of the registered callback throw. I'm just not sure that's a doable java pattern

But yeah, it's a good thing to dig into before GA!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants