Skip to content

GH-10083: Migrate spring-integration-ws module to Jspecify #10098

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

anthologia
Copy link
Contributor

Related to: #10083

  • Replace org.springframework.lang.Nullable with org.jspecify.annotations.Nullable
  • Migrate package-info.java files to use @NullMarked annotation
  • Add @SuppressWarnings("NullAway.Init") for fields initialized in lifecycle methods

For the array fields BaseWsOutboundGatewaySpec.messageSenders and BaseWsOutboundGatewaySpec.gatewayInterceptors, I applied @SuppressWarnings("NullAway.Init") instead of @Nullable because adding @Nullable still produces the same NullAway warnings.

…pecify

Related to: spring-projects#10083

- Replace `org.springframework.lang.Nullable` with `org.jspecify.annotations.Nullable`
- Migrate `package-info.java` files to use `@NullMarked` annotation
- Add `@SuppressWarnings("NullAway.Init")` for fields initialized in lifecycle methods

Signed-off-by: Jooyoung Pyoung <[email protected]>
@anthologia
Copy link
Contributor Author

I found some packages don't have @org.jspecify.annotations.NullMarked applied.. I'll add them in a follow-up commit !

@artembilan
Copy link
Member

I'll add them in a follow-up commit !

Right. Let's finish with the current change you have so far and then we will go from there for others.
If that is more convenient for you, we may even go separate PRs.

Thanks

- Use proper array nullability: `WebServiceMessageSender @nullable []`
- Fix inner class annotation placement: `DefaultUriBuilderFactory.@nullable EncodingMode`
- Set default Jaxb2Marshaller for gatewayMarshaller field

Signed-off-by: Jooyoung Pyoung <[email protected]>
@anthologia
Copy link
Contributor Author

anthologia commented Jun 11, 2025

I've applied all the requested changes!

  • Set gatewayMarshaller to use Jaxb2Marshaller as default since it's an implementation of Marshaller. Thanks!
  • Updated all @Nullable annotations to be placed between access modifier and type for consistency.
    • Should we standardize @Nullable placement convention project-wide? 🤔 Currently there seems to be mixed usage.

I'll add commits tomorrow for other packages in the ws module to this PR rather than separate PRs! Is that fine?

@artembilan
Copy link
Member

Currently there seems to be mixed usage.

I know, but the easier way to proceed is to replace imports and leave as is.
We can clean up the proper placement as we will go eventually.
If that is fine for you, feel free to make it as it is recommended by JSpecify, but I'm not picky on that.

It is fine to continue in this PR.

Thanks.

* Add `@NullMarked` to all the `ws` packages
* Add `@Nullable` or `@SuppressWarnings("NullAway.Init")` whenever it is requested
* Add defensive null checks for better safety (`DefaultSoapHeaderMapper`, `SimpleWebServiceOutboundGateway`)

Signed-off-by: Jooyoung Pyoung <[email protected]>
@@ -84,15 +87,17 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro

private boolean webServiceTemplateExplicitlySet;

public AbstractWebServiceOutboundGateway(final String uri, WebServiceMessageFactory messageFactory) {
@SuppressWarnings("NullAway")
public AbstractWebServiceOutboundGateway(final String uri, @Nullable WebServiceMessageFactory messageFactory) {
Copy link
Member

Choose a reason for hiding this comment

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

This is not correct.
The WebServiceTemplate expects from us a WebServiceMessageFactory as a not null.
If you see somewhere it is, let's mitigate it over there!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

then.. when ctors pass null for WebServiceMessageFactory, I'll replace null with SaajSoapMessageFactory as the default. Does this sound good?

Based on the WebServiceTemplate.properties, SaajSoapMessageFactory is indeed the default strategy.

Copy link
Member

Choose a reason for hiding this comment

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

Why would we allow to pass null at all?
The WebServiceTemplate does not expect that from us, so let's comeback to not-null for this ctors!

Copy link
Contributor Author

@anthologia anthologia Jun 12, 2025

Choose a reason for hiding this comment

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

Right, I meant that I'll remove @Nullable from the constructor parameters and fix the calling sites to pass SaajSoapMessageFactory instance instead of null.

For example:

// Instead of
super(uri, null);

// I'll change to  
super(uri, new SaajSoapMessageFactory());

Am I still misunderstanding something?

Copy link
Member

Choose a reason for hiding this comment

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

I see:

	public MarshallingWebServiceOutboundGateway(DestinationProvider destinationProvider,
			WebServiceTemplate webServiceTemplate) {
		super(destinationProvider, null);
		doSetWebServiceTemplate(webServiceTemplate);
	}

I think it is better to introduce a protected ctor in the AbstractWebServiceOutboundGateway based on the WebServiceTemplate then.

@@ -68,7 +69,7 @@ public SimpleWebServiceOutboundGateway(DestinationProvider destinationProvider,

public SimpleWebServiceOutboundGateway(DestinationProvider destinationProvider,
@Nullable SourceExtractor<?> sourceExtractor,
WebServiceMessageFactory messageFactory) {
@Nullable WebServiceMessageFactory messageFactory) {
Copy link
Member

Choose a reason for hiding this comment

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

We have to fix those places to not provide a null for the WebServiceMessageFactory.

super(destinationProvider, messageFactory);
configureMarshallers(marshaller, unmarshaller);
}

@SuppressWarnings("NullAway")
Copy link
Member

Choose a reason for hiding this comment

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

I'm not very OK with these @SuppressWarnings("NullAway"), but we can look into that separately if that is too much for this change cycle.

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

Successfully merging this pull request may close these issues.

2 participants