简体   繁体   English

在IBM WebSphere上运行的意外异常java.math.BigDecimal

[英]unexpected exception java.math.BigDecimal running on IBM WebSphere

Running Java application on IBM WebSphere caused such exception: 在IBM WebSphere上运行Java应用程序会导致以下异常:

Caused by: java.lang.NullPointerException
at java.math.BigDecimal.add2DFP(BigDecimal.java:1946)
at java.math.BigDecimal.add(BigDecimal.java:1881)
at com.somepackage.components.view.PremiumSummaryViewModel.setPremiums(PremiumSummaryViewModel.java:101)

Null check is done. 空检查完成。 As I reviewed java.math.BigDecimal class has no such method add2DFP and does not call one either. 当我查看java.math.BigDecimal类时,没有此类方法add2DFP ,也未调用任何方法。 Maybe it's specific to IBM's JDK. 也许它特定于IBM的JDK。

Any comment on this would be appreciated. 任何对此的评论将不胜感激。

Providing code regarding to exception 提供有关异常的代码

    BigDecimal annualPremiumAmt = nwtPremium != null && nwtPremium.getAnnualAmt() != null ? nwtPremium.getAnnualAmt() : BigDecimal.ZERO;
    if (nwtPremium != null) {
        BigDecimal formPremiumAmt = nwtPremium.getAnnualAmt();
        if (formPremiumAmt != null) {
            policyFormTotal = policyFormTotal.add(annualPremiumAmt); //Bigdecimal
            formList.setFormPremiumAmt(formList.getFormPremiumAmt().add(annualPremiumAmt)); //101 line
        }
    }

Instance is running on IBM JDK 1.6. 实例在IBM JDK 1.6上运行。

I would submit your issues to IBM Software Support. 我会将您的问题提交给IBM软件支持。 They don't charge per instance, it's unlimited amount of requests as long as you have a support agreement. 他们不会按实例收费,只要您有支持协议,它的请求数量是无限的。

Fixed: 固定:

Actually this whole expression is inside the loop that I thought was unnecessary to mention. 实际上,整个表达式位于我认为没有必要提及的循环内。 I have moved declaration of BigDecimal annualPremiumAmt before the loop and reorganized code: 我在循环之前将BigDecimal AnnualPremiumAmt的声明移到了前面,并重新组织了代码:

BigDecimal annualPremiumAmt;
for(...) { 

    if (nwtPremium) {
        annualPremiumAmt = nwtPremium.getAnnualAmt() != null ? nwtPremium.getAnnualAmt() : BigDecimal.ZERO;
        policyFormTotal = policyFormTotal.add(annualPremiumAmt);
        formList.setFormPremiumAmt(formList.getFormPremiumAmt().add(annualPremiumAmt));
    }
}

Is policyFormTotal NULL? policyFormTotal是否为NULL? How about the result of formList.getFormPremiumAmt()? formList.getFormPremiumAmt()的结果如何? You never check those in this code block. 您永远不会在此代码块中检查这些代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM