Skip to content

Add serialVersionUID to MessageHistory #3738

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

Merged

Conversation

onobc
Copy link
Contributor

@onobc onobc commented Mar 6, 2022

@artembilan not sure what test to add for this one. We could do this:

  • Serialize a 5.1 MessageHistory to disk.
  • Put that file in test/resources
  • Deserialize the file w/ the latest MessageHIistory.
    I'm not sure if this is worth adding to automation though. It is somewhat a one-off and should not be an issue again in this class.

Fixes gh-3737

@onobc onobc force-pushed the cbono/gh-3737-serialversionid-msghist branch 2 times, most recently from e11ebd9 to 633527f Compare March 6, 2022 23:30
Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

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

Yes, I agree it is pointless to waste our time figuring out how to test it in JUnit.

It is really would be enough to test it once.
We may just accept this PR and merge.
And then ask @german22 to test his project against latest 5.5.10-SNAPSHOT.

Just check the project and other similar entities are OK, even if they just only have serialVersionUID = 1L.

Although I feel as we have to add an explicit one to all the ApplicationEvent impls, and exceptions, like ReplyRequiredException...

WDYT?

Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

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

After removing that suppression we got now this:

/home/runner/work/spring-integration/spring-integration/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistory.java:312: warning: [serial] serializable class Entry has no definition of serialVersionUID
	public static class Entry extends Properties {
	              ^

So, it has to be fixed with an explicit (extracted) serialVersionUID as well.

@artembilan
Copy link
Member

We are not ready to merge this yet.
Even if this will fix data stored from the 5.5.1.
But what about the data stored already starting with 5.5.2?

We have to come up somehow with a solution which could deal with old and new class versions...

@onobc onobc force-pushed the cbono/gh-3737-serialversionid-msghist branch from fa9fde4 to 8d6068a Compare March 8, 2022 05:40
Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

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

That's great, @onobc !

But I believe we should leave such a workaround outside of the framework code even for the current version we are going to fix it for.

Better to have a single workaround class (even with that VersionTolerantObjectInputStream as nested) and show it in the issue for end-user.

The fix has to be like an explicit for the current MessageHistory class version - serialVersionUID = -2340400235574314134L.

So, it is not going to be a break point in the next 6.0.

(I don't think we will migrate a MessageHistory to the record as IDE suggests...)

@onobc
Copy link
Contributor Author

onobc commented Mar 8, 2022

That's great, @onobc !

But I believe we should leave such a workaround outside of the framework code even for the current version we are going to fix it for.

Better to have a single workaround class (even with that VersionTolerantObjectInputStream as nested) and show it in the issue for end-user.

Sounds good @artembilan . Yep, I was not wanting to actually merge it in - but figure out where to put it. The docs idea in a single class sounds good. I will put it in a branch locally (just to keep around for later if needed), consolidate it into single class, and produce a HowTo in the issue w/ the code sample.

I will close this PR once I update the issue w/ the sample code.

The fix has to be like an explicit for the current MessageHistory class version - serialVersionUID = -2340400235574314134L.

Yep, that was in the javadoc at the top of the deserializer on how to use. I will make it clear in the issue when I comment.

So, it is not going to be a break point in the next 6.0.

(I don't think we will migrate a MessageHistory to the record as IDE suggests...)

Yeh - no changes to framework should come out of this PR at all.

@artembilan
Copy link
Member

I mean, Chris, that current MessageHistory has to got that serialVersionUID = -2340400235574314134L. And that's exactly what we will merge and back-port.
It is not going to be a breaking change at all: just will let us to avoid similar issue in the future when we would change something in the MessageHistory breaking its class version.

@onobc onobc force-pushed the cbono/gh-3737-serialversionid-msghist branch from 2834e4e to 7aefb05 Compare March 8, 2022 19:41
@onobc
Copy link
Contributor Author

onobc commented Mar 8, 2022

I mean, Chris, that current MessageHistory has to got that serialVersionUID = -2340400235574314134L. And that's exactly what we will merge and back-port. It is not going to be a breaking change at all: just will let us to avoid similar issue in the future when we would change something in the MessageHistory breaking its class version.

Ahh yeh. Makes sense. Explicitly set the serialVersionUID in MH. I will amend this PR to do that.

@onobc
Copy link
Contributor Author

onobc commented Mar 8, 2022

Ignore the latest commits. I intended those to a separate branch for safe-keeping. I will clean this up shortly.

@onobc onobc force-pushed the cbono/gh-3737-serialversionid-msghist branch from 7aefb05 to 323c88a Compare March 8, 2022 20:40
public final class MessageHistory implements List<Properties>, Serializable {

private static final long serialVersionUID = -2340400235574314134L;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cbono@cbono-a01 server-main % serialver -classpath spring-context-5.3.14.jar:spring-context-support-5.3.14.jar:spring-core-5.3.14.jar:spring-integration-core-5.5.8-SNAPSHOT.jar:spring-jcl-5.3.14.jar:spring-messaging-5.3.14.jar org.springframework.integration.history.MessageHistory
org.springframework.integration.history.MessageHistory:    private static final long serialVersionUID = -2340400235574314134L;

/**
* Inner class for each Entry in the history.
*/
public static class Entry extends Properties {

private static final long serialVersionUID = -8225834391885601079L;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cbono@cbono-a01 server-main % serialver -classpath spring-context-5.3.14.jar:spring-context-support-5.3.14.jar:spring-core-5.3.14.jar:spring-integration-core-5.5.8-SNAPSHOT.jar:spring-jcl-5.3.14.jar:spring-messaging-5.3.14.jar org.springframework.integration.history.MessageHistory.Entry
org.springframework.integration.history.MessageHistory.Entry:    private static final long serialVersionUID = -8225834391885601079L;

@onobc onobc force-pushed the cbono/gh-3737-serialversionid-msghist branch from 323c88a to 87b5c40 Compare March 8, 2022 21:03
@onobc onobc requested a review from artembilan March 8, 2022 21:04
@artembilan artembilan merged commit ba8a26f into spring-projects:main Mar 8, 2022
@artembilan
Copy link
Member

... and cherry-picked to 5.5.x.

Thanks, @onobc ; looking forward for more!

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.

SerialVersionUID on class MessageHistory Breaking change : from version 5.5.2 to latest
2 participants