Announcement Announcement Module
Collapse
No announcement yet.
DefaultFieldSet: Thread Safety Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DefaultFieldSet: Thread Safety

    Hi,

    When working on a spring batch based application, I encountered an error related to SimpleDateFormat.

    After some investigation, the cause of the error was related to the un-synchronized use of SimpleDateFormat in org.springframework.batch.item.file.transform.Defa ultFieldSet.

    Possible solution: create a new instance of SimpleDateFormat in each method that reads a date field.

    Example:

    Code:
    public Date readDate(int index) {
                    DateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_PATTERN);
    		return parseDate(readAndTrim(index), dateFormat);
    	}
    Thanks

  • #2
    Good catch. A quick look through the code shows that we're making the same mistake with NumberFormat. I've opened a Jira issue to track this going forward: https://jira.springsource.org/browse/BATCH-1932

    Comment


    • omerbeimnet
      omerbeimnet commented
      Editing a comment
      BATCH-1932 has resolution 'Works as Designed'. I am confused.
Working...
X