Changeset 5769


Ignore:
Timestamp:
Sep 29, 2011, 10:44:38 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1632: NullPointerException? when using JEP mapping for column with string values

The reason for the NullPointerException? was that we tried to convert the string to a double. This is now fixed and I have also changed JEP to pass on exceptions instead of swallowing them. I hope that doesn't cause problems elsewhere.

Location:
trunk/src/core/net/sf/basedb/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/jep/FunctionSafeJep.java

    r5689 r5769  
    3131import org.nfunk.jep.FunctionTable;
    3232import org.nfunk.jep.JEP;
     33import org.nfunk.jep.Node;
    3334import org.nfunk.jep.ParseException;
    3435import org.nfunk.jep.Token;
     
    7778    this.errorList.add(error);
    7879  }
    79  
     80
     81  /**
     82    Override the superclass method so that exceptions are passed on
     83    instead of swallowed.
     84    @since 3.0
     85  */
     86  @Override
     87  public Object getValueAsObject()
     88  {
     89    Node topNode = getTopNode();
     90    if (topNode == null || hasError()) return null;
     91    try
     92    {
     93      return this.ev.getValue(topNode, this.symTab);
     94    }
     95    catch (ParseException ex)
     96    {
     97      throw new RuntimeException(ex);
     98    }
     99  }
     100
    80101  /**
    81102    Function table implementation that pretends that all possible functions
  • trunk/src/core/net/sf/basedb/util/parser/ColFunction.java

    r4515 r5769  
    170170      {
    171171        pos.setIndex(0);
    172         d = numberFormat.parse(value, pos).doubleValue();
    173         if (pos.getIndex() < value.length())
     172        Number n = numberFormat.parse(value, pos);
     173        if (n == null || pos.getIndex() < value.length())
    174174        {
    175175          stack.push(value);
    176176          return;
    177177        }
     178        d = n.doubleValue();
    178179      }
    179180    }
Note: See TracChangeset for help on using the changeset viewer.