Uploaded image for project: 'Apache NiFi MiNiFi C++'
  1. Apache NiFi MiNiFi C++
  2. MINIFICPP-751

RAII over JNI UTF strings

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 0.6.0
    • None

    Description

      In this PR #489 I've noticed that JNI UTF string usage is error-prone as releasing can be easily missed by the developer or simply get skipped because of an exception. 

      To avoid this my idea was to create a wrapper object that can be used as an std::string and handles get/release calls.

      As phrocker pointed out, this object has to be kept in a small block to avoid storing ref on both the string itself and the JNI env. 

      This can partly be achieved by blocking copy/move construction/assigment and new, but still leaves some possibility to allocate this object on heap. 

      In my opinion the restrictions above with some comments in the class would help and make it safer, although I'm not sure it worth the effort.

       

      phrocker, aldrin, what's your opinion?

      Attachments

        Issue Links

          Activity

            People

              aboda Arpad Boda
              aboda Arpad Boda
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m