[rules-users] exception jitting problem

brendanneff brendan.neff+droolsforum at gmail.com
Fri Sep 14 12:55:57 EDT 2012


Mario Fusco wrote
> 
> I think I've fixed all the outstanding jitting issues and these fixes will
> be available in the upcoming 5.5 release (we are deploying the beta1 in
> these days). However it would be great if I could reproduce the bugs you
> found, both because I could check if they are actually fixed in the 5.5
> and possibly give you some more informed suggestions to workaround them in
> the 5.4. In order to do that, the only info I miss is how the
> CMVNewLoanBean class is made. Could you please send its source code (or at
> least the parts relevant for the 2 failing rules you have) ?
> 

I'm not sure how to answer that question, but hopefully this will be a
start.  I can provide more if you have specifics or if I'm going in the
wrong direction.

public class CMVNewLoanBean extends CMVBaseRequestBean {

	private CMVCustomerBean customer = null;
	private Map<String,CMVLenderBean> activeLenders = new
HashMap<String,CMVLenderBean>();
	
	public CMVCustomerBean getCustomer() {
		if (customer == null) {
			customer = new CMVCustomerBean();
		}
		return customer;
	}

	public void setCustomer(CMVCustomerBean customer) {
		this.customer = customer;
	}
		
	public Map<String,CMVLenderBean> getActiveLenders() {
		return activeLenders;
	}

	public void setActiveLenders(Map<String,CMVLenderBean> activeLenders) {
		this.activeLenders = activeLenders;
	}
	
	public CMVLenderBean getActiveLender(String lenderName) {
		return activeLenders.get(lenderName);
	}
}


public class CMVEmployerBean {

	public enum PERIODICITY {
		BI_WEEKLY ("B"),
		MONTHLY ("M"),
		SEMI_MONTHLY ("S"),
		WEEKLY ("W");
		
		private final String periodicity;
		PERIODICITY(String periodicity) {
			this.periodicity = periodicity;
		}
		
		public String getPeriodicity() {
			return periodicity;
		}
		
	}

	private PERIODICITY periodicity = null;	
	private String averagePayCheck = ""; //amount per pay check
	
	public String getAveragePayCheck() {
		return averagePayCheck;
	}

	public void setAveragePayCheck(String averagePayCheck) {
		this.averagePayCheck = averagePayCheck;
	}
	
	public Integer getMonthlySalary() {
		
		Integer monthlySalary = 0;
		
		if (!averagePayCheck.equals("") && !periodicity.equals(null)) {
			monthlySalary = ((Double)
StringUtils.getNumber(averagePayCheck)).intValue();
			
			if (periodicity.equals(PERIODICITY.SEMI_MONTHLY) ||
periodicity.equals(PERIODICITY.BI_WEEKLY)) {
				monthlySalary = monthlySalary * 2;
			} else if (periodicity.equals(PERIODICITY.WEEKLY)) {
				monthlySalary = monthlySalary * 4;
			}
			
		} else {
			throw new NumberFormatException("The monthly salary was requested but
either the periodicity (" + periodicity + ") or the average pay check (" +
averagePayCheck + ") is not valid.");
		}
		
		return monthlySalary;
	}
}


public class CMVCustomerBean {

	private List<CMVEmployerBean> employers = new ArrayList<CMVEmployerBean>();
	
		public List<CMVEmployerBean> getEmployers() {
		return employers;
	}

	public boolean addEmployer(CMVEmployerBean employer) {
		employers.add(employer);
		return true;
	}

	public CMVEmployerBean getEmployer(int index) {
		CMVEmployerBean employer = null;
		if (this.employers.size() <= index) {
			employer = new CMVEmployerBean();
			employers.add(employer);
		} else {
			employer = this.employers.get(index);
		}
		
		return employer;
	}
	
	public CMVEmployerBean getLatestEmployer() {
		return getEmployer(0);
	}
	
	public void setEmployers(List<CMVEmployerBean> employers) {
		this.employers = employers;
	}
}



Mario Fusco wrote
> 
> 
> brendanneff wrote
>> 
>> Here are the rules that seem to be causing the errors:
>> 
>> rule "Cashcure - Average Monthly Income Less Than 1251"
>>     when
>>         $loan : CMVNewLoanBean( new
>> Integer(getCustomer().getLatestEmployer().monthlySalary) < 1251)
>>     then
>>         $loan.setLenderError($loan.getCurrentLender().getName(), 20253);
>> end
>> 
> 
> Out of curiosity, why do you create the new Integer there instead of just
> doing:
> 
> CMVNewLoanBean( getCustomer().getLatestEmployer().monthlySalary < 1251)
> 

I don't have a good answer for that as it came that way, but I was wondering
the same thing.  I'll try making that switch and see if it has any effect.



--
View this message in context: http://drools.46999.n3.nabble.com/exception-jitting-problem-tp4019763p4019796.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list