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

JSR356 Encoder#init is not called when created on demand #1100

Closed
fbuecklers opened this issue Nov 15, 2016 · 8 comments
Closed

JSR356 Encoder#init is not called when created on demand #1100

fbuecklers opened this issue Nov 15, 2016 · 8 comments
Assignees

Comments

@fbuecklers
Copy link
Contributor

fbuecklers commented Nov 15, 2016

I have created a BaseMessage class and 3 sub classes wich can be converted by one generic Encoder<BaseMessage> encoder.

Jetty correctly creates encoders for my subclasses but the init methods of the created Encoders are not called.

The reason seems to be in EncoderFactory#getWrapperFor implementation where the on demand wrapper creation doesn't call the Encoder#init method after creation.

Testet with Jetty 9.3.14.v20161028

@joakime joakime added the Bug For general bugs on Jetty side label Nov 15, 2016
@joakime joakime self-assigned this Nov 15, 2016
@joakime
Copy link
Contributor

joakime commented Nov 22, 2016

Cannot replicate this.

Do you have a sample project that can replicate this?

@joakime joakime added More Info Required and removed Bug For general bugs on Jetty side labels Dec 27, 2016
@joakime
Copy link
Contributor

joakime commented Mar 15, 2017

Unable to Replicate. Feel free to reopen if you have a reproduction case.

@joakime joakime closed this as completed Mar 15, 2017
@ericljiang
Copy link

I'm encountering this in 9.4.18.v20190429. It seems very similar to #425. Jetty constructs and initializes (calls init()) an encoder instance upon connection but never uses it. Instead it creates a new instance upon calling session.getBasicRemote().sendObject(event) and never calls init() on the new instance. Debugging shows that the second instance is created by the same code @fbuecklers referenced:
https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/EncoderFactory.java#L139-L147

Working on providing a sample project soon.

@joakime joakime reopened this Jun 9, 2019
@joakime
Copy link
Contributor

joakime commented Jun 9, 2019

@ericljiang interesting discovery. reopened.

@joakime
Copy link
Contributor

joakime commented Jun 18, 2020

@lachlan-roberts do you recall any changes on jetty-9.4.x related to this?

I cannot seem to replicate this.

@lachlan-roberts
Copy link
Contributor

@joakime not that I can recall, I don't think I've touched encoders in 9.4.
I'll take a closer look and see if I can replicate the issue.

@lachlan-roberts
Copy link
Contributor

@joakime I was able to reproduce this and have proposed a fix in PR #4987.

lachlan-roberts added a commit that referenced this issue Jun 22, 2020
…erLifeCycle

Issue #1100 - ensure init and destroy are always called on JSR356 Encoders
@lachlan-roberts
Copy link
Contributor

The fix for this has been merged into 9.4.x with PR #4987 and will be available in a 9.4.31 release.

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

No branches or pull requests

4 participants