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

Fix Thread-Safety in the SyslogToMapTransformer [INT-3715] #7671

Closed
spring-operator opened this issue May 8, 2015 · 4 comments
Closed

Fix Thread-Safety in the SyslogToMapTransformer [INT-3715] #7671

spring-operator opened this issue May 8, 2015 · 4 comments

Comments

@spring-operator
Copy link
Contributor

Alvaro Vega opened INT-3715 and commented

Syslog-udp module is creating wrong timestamp fields (even another numeric fields are bad transformed)
Checking the output from Java Mission Control, we have seen that Spring Integration component udp-inbound-channel-adapter is used, and also DatagramPacketMessageMapper in method toMessage, and in here might be the problem in a concurrent environment, with different threads accessing some share variable.
Attatch a file, with the syslog entry sent in a loop, and different output obtained for the same entry.
We used a simple stream syslog-udp | file in a Spring XD single-node, and also failed in a distributed way.


Affects: 4.1.3

Attachments:

Referenced from: pull request #1443

Backported to: 4.0.8, 3.0.8

@spring-operator
Copy link
Contributor Author

Karol Dowbecki commented

org.springframework.integration.transformer.SyslogToMapTransformer#transform(String) is being invoked by multiple ip:udp-inbound-channel-adapter threads. This method is accessing SyslogToMapTransformer#dateFormat field implemented with SimpleDateFormat without any synchronization.

Although one can create new local SimpleDateFormat object or use ThreadLocal perhaps spring-integration-syslog should use a thread-safe formatter e.g. FastDateFormat from commons-lang?

@spring-operator
Copy link
Contributor Author

Gary Russell commented

Hi Karol Dowbecki

We can't add a new dependency to 4.1.x, but we can look at doing so for 4.2.x

In the meantime, we can use a pool.

@spring-operator
Copy link
Contributor Author

Karol Dowbecki commented

I've checked commons-lang 3.4 and 3.5-SNAPSHOT and unfortunately FastDateFormat is not a drop-in replacement for SimpleDateFormat:

  1. MMM pattern is case-sensitive e.g. "may" parses but "May" doesn't. Both values work with SimpleDateFormat.
  2. Leading zeros in dd are required e.g. "08" parses but " 8" doesn't. Both values work with SimpleDateFormat.

Please ignore my previous comment about commons-lang.

@spring-operator
Copy link
Contributor Author

Gary Russell commented

Thanks; I guess we'll stick with what I did in the PR.

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

No branches or pull requests

2 participants