Menu

#253 ConverterPrimitiveTypes made with #242 breaks existing software

v1.0 (example)
open
None
5
2025-06-01
2025-01-23
No

The changes in ConverterPrimitiveTypes made with #242 breaks our software. Before these changes, opencsv used it's own ConvertUtilsBean but now it uses the BeanUtilsBean.getInstance().getConvertUtils() instance and re-registered the converters with throwException=true. That causes issues in our application because we need to have the "global" ConvertUtilsBean with throwException=false so that the default values are used.
Maybe opencsv could create and use it's own singleton of ConvertUtilsBean so that it does not interfere with others using BeanUtilsBean.getInstance() ?
Unfortunately I can't change that part of our software because that's also kind of a library.
I'm new to SourceForge but I could create a PR if that helps?

Discussion

  • Scott Conway

    Scott Conway - 2025-01-27
    • assigned_to: Scott Conway
     
  • Scott Conway

    Scott Conway - 2025-01-27

    Hello Setfan - go ahead and send a PR if you have some sample code (and hopefully test) and I will do my best to look at it this weekend.

    Right now I am thinking of changing the ConverterPrimitiveTypes code that is doing the register from :

    if(this.locale == null) {
                readConverter = BeanUtilsBean.getInstance().getConvertUtils();
                readConverter.register(true, false, 0);
                readLocaleConverter = null;
            }
    

    to

      if(this.locale == null) {
    readConverter = BeanUtilsBean.getInstance().getConvertUtils();
    readLocaleConverter = null;
    if (BeanUtilsBean.getInstance().getConvertUtils().lookup(type) == null) {
        readConverter.register(true, false, 0);
    }
    

    }

    This way nothing is registered if something is already registered. I am a little concerned because for giggles I changed the throwException in the original code from true to false and none of the existing tests broke. This is why I have no problems changing the code like I did above. But if you have tests that show somehow that if you did set the converter beforehand that is the one that will be used it would be a big help... but I won't hold up the changes if it is not there.

     
  • Scott Conway

    Scott Conway - 2025-04-20
    • status: open --> pending
     
  • Scott Conway

    Scott Conway - 2025-04-20

    The above mentioned fix has been merged in for both the read and write converters and will go out in the next release.

     
  • Scott Conway

    Scott Conway - 2025-06-01
    • status: pending --> open
     
  • Scott Conway

    Scott Conway - 2025-06-01

    I am reverting this back to open and rolling back my changes and will reopen #242 as well. I need to create a test that shows what is happening with the converters being overwritten and then find a way to determine if a custom converter has been registered and not re-register all converters like is currently being done.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.