Uploaded image for project: 'Lucee Development'
  1. LDEV-622

Cannot use a Map as a struct with null value

    Details

    • Type: Bug
    • Status: Deployed
    • Priority: New
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0.0.165, 4.5.3.003
    • Labels:
      None

      Description

      I was working with some Java code that returned a java Map that had a key that was null. Any attempts of appending that Map to a struct or iterating over it as a collection return a NPE. I was forced to manually loop over the Map and get all the keys out individually.

      This is what the Map contained (formatted as JSON):

      "HEADERS":{
      "Content-Length":"333",
      "Date":"Fri, 13 Nov 2015 20:29:07 GMT",
      "Server":"SurgeCDN/0.12.1",
      "Vary":"Accept-Encoding",
      "ETag":"\"52e5d179a350a9655d139c9c18a09937\"",
      "":null,
      "Accept-Ranges":"bytes",
      "Response-Time":"7ms",
      "Content-Type":"text/html; charset=UTF-8",
      "Cache-Control":"public, max-age=31536000, no-cache"
      },

      Here is an example of an error. When running the following code:

      foo = {}.append( connection.getHeaderFields() );
      

      I get the following error:

      java.lang.NullPointerException
      at lucee.runtime.type.wrap.MapAsStruct.keys(MapAsStruct.java:82):82
      at lucee.runtime.type.wrap.MapAsStruct.keyIterator(MapAsStruct.java:169):169
      at lucee.runtime.functions.struct.StructAppend.call(StructAppend.java:42):42
      at lucee.runtime.functions.struct.StructAppend.call(StructAppend.java:39):39
      at lucee.runtime.functions.struct.StructAppend.invoke(StructAppend.java:55):55
      at lucee.runtime.interpreter.ref.func.BIFCall.getValue(BIFCall.java:137):137
      at lucee.runtime.type.util.MemberUtil.call(MemberUtil.java:101):101
      at lucee.runtime.type.util.StructSupport.call(StructSupport.java:256):256
      at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:743):743
      at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1586):1586
      at system.util.progressabledownloader_cfc$cf.udfCall(C:\Users\Brad.development\.CommandBox\cfml\system\util\ProgressableDownloader.cfc:112):112

        Attachments

          Activity

            People

            • Assignee:
              michaeloffner Michael Offner
              Reporter:
              bdw429s Brad Wood
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: