java.lang.RuntimeException: Exception occurred on line 7 while setting value 0 for property totalTransactionFeeCreditAmount.

Kuali JIRA | Ying Feng | 2 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    https://uisapp2.iu.edu/jira-prd/browse/FSKI-411 While working on a new Flat File type that uses ExplicitKualiDecimalFormatter for amount fields, I encountered the following parsing exception: {code} 2015-02-10 11:29:27,156 [pool-12-thread-1] u:/d: ERROR org.kuali.kfs.sys.batch.FlatFileParserBase :: Exception occurred on line 7 while setting value 0 for property totalTransactionFeeCreditAmount. happend in parsing file content java.lang.RuntimeException: Exception occurred on line 7 while setting value 0 for property totalTransactionFeeCreditAmount. at org.kuali.kfs.sys.batch.AbstractFlatFilePropertySpecificationBase.setProperty(AbstractFlatFilePropertySpecificationBase.java:68) at org.kuali.kfs.sys.batch.DelimitedFlatFileSpecification.parseLineIntoObject(DelimitedFlatFileSpecification.java:40) at org.kuali.kfs.sys.batch.FlatFileParserBase.parse(FlatFileParserBase.java:127) at org.kuali.kfs.sys.batch.service.impl.BatchInputFileServiceImpl.parse(BatchInputFileServiceImpl.java:56) at edu.iu.ebs.kfs.module.cmrc.batch.service.impl.PaypalProcessTransactionServiceImpl.parseTransactionFile(PaypalProcessTransactionServiceImpl.java:231) at edu.iu.ebs.kfs.module.cmrc.batch.service.impl.PaypalProcessTransactionServiceImpl.loadTransactions(PaypalProcessTransactionServiceImpl.java:141) at edu.iu.ebs.kfs.module.cmrc.batch.PaypalLoadTransactionsStep$1.execute(PaypalLoadTransactionsStep.java:22) ...... Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1911) at org.kuali.kfs.sys.businessobject.format.ExplicitKualiDecimalFormatter.addDecimalPoint(ExplicitKualiDecimalFormatter.java:51) at org.kuali.kfs.sys.businessobject.format.ExplicitKualiDecimalFormatter.convertToObject(ExplicitKualiDecimalFormatter.java:39) at org.kuali.rice.core.web.format.Formatter.convertFromPresentationFormat(Formatter.java:427) at org.kuali.kfs.sys.batch.AbstractFlatFilePropertySpecificationBase.getFormattedObject(AbstractFlatFilePropertySpecificationBase.java:135) at org.kuali.kfs.sys.batch.AbstractFlatFilePropertySpecificationBase.setProperty(AbstractFlatFilePropertySpecificationBase.java:65) ... 24 more {code} The root cause is that ExplicitKualiDecimalFormatter.addDecimalPoint assumes that the amount string always has at least 2 chars. {code} private String addDecimalPoint (String amount) { if (!amount.contains(".")) { //have to add decimal point if it's missing int length = amount.length(); amount = amount.substring(0, length - 2) + "." + amount.substring(length - 2, length); } return amount; } {code} But that's not the case. For ex, In the above exception, we encountered amount string "0", which has only 1 char, and thus we got index out of bound exception. We shall add logic to handle this situation, as I think 0 amount string is quite common in any amount field using implicit decimal point.

    Kuali JIRA | 2 years ago | Ying Feng
    java.lang.RuntimeException: Exception occurred on line 7 while setting value 0 for property totalTransactionFeeCreditAmount.

    Root Cause Analysis

    1. java.lang.RuntimeException

      Exception occurred on line 7 while setting value 0 for property totalTransactionFeeCreditAmount.

      at org.kuali.kfs.sys.batch.AbstractFlatFilePropertySpecificationBase.setProperty()
    2. org.kuali.kfs
      BatchInputFileServiceImpl.parse
      1. org.kuali.kfs.sys.batch.AbstractFlatFilePropertySpecificationBase.setProperty(AbstractFlatFilePropertySpecificationBase.java:68)
      2. org.kuali.kfs.sys.batch.DelimitedFlatFileSpecification.parseLineIntoObject(DelimitedFlatFileSpecification.java:40)
      3. org.kuali.kfs.sys.batch.FlatFileParserBase.parse(FlatFileParserBase.java:127)
      4. org.kuali.kfs.sys.batch.service.impl.BatchInputFileServiceImpl.parse(BatchInputFileServiceImpl.java:56)
      4 frames
    3. edu.iu.ebs
      PaypalLoadTransactionsStep$1.execute
      1. edu.iu.ebs.kfs.module.cmrc.batch.service.impl.PaypalProcessTransactionServiceImpl.parseTransactionFile(PaypalProcessTransactionServiceImpl.java:231)
      2. edu.iu.ebs.kfs.module.cmrc.batch.service.impl.PaypalProcessTransactionServiceImpl.loadTransactions(PaypalProcessTransactionServiceImpl.java:141)
      3. edu.iu.ebs.kfs.module.cmrc.batch.PaypalLoadTransactionsStep$1.execute(PaypalLoadTransactionsStep.java:22)
      3 frames