[ 1732480 ] Improve callout recursive call detection
- remove use of static - remove duplicate code
This commit is contained in:
parent
fabb160c53
commit
137dad5b5f
|
@ -165,24 +165,26 @@ public class CalloutEngine implements Callout
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
private static boolean s_calloutActive = false;
|
//private static boolean s_calloutActive = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is Callout Active
|
* Is Callout Active
|
||||||
|
* @deprecated
|
||||||
* @return true if active
|
* @return true if active
|
||||||
*/
|
*/
|
||||||
protected static boolean isCalloutActive()
|
protected static boolean isCalloutActive()
|
||||||
{
|
{
|
||||||
return s_calloutActive;
|
return false;
|
||||||
} // isCalloutActive
|
} // isCalloutActive
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Callout (in)active
|
* Set Callout (in)active
|
||||||
|
* @deprecated
|
||||||
* @param active active
|
* @param active active
|
||||||
*/
|
*/
|
||||||
protected static void setCalloutActive (boolean active)
|
protected static void setCalloutActive (boolean active)
|
||||||
{
|
{
|
||||||
s_calloutActive = active;
|
; //no op
|
||||||
} // setCalloutActive
|
} // setCalloutActive
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2350,6 +2350,18 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
} // processDependencies
|
} // processDependencies
|
||||||
|
|
||||||
|
|
||||||
|
private List<String> activeCallouts = new ArrayList<String>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return list of active call out for this tab
|
||||||
|
*/
|
||||||
|
public String[] getActiveCallouts()
|
||||||
|
{
|
||||||
|
String[] list = new String[activeCallouts.size()];
|
||||||
|
return activeCallouts.toArray(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Process Callout(s).
|
* Process Callout(s).
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -2365,7 +2377,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
* @return error message or ""
|
* @return error message or ""
|
||||||
* @see org.compiere.model.Callout
|
* @see org.compiere.model.Callout
|
||||||
*/
|
*/
|
||||||
private String processCallout (GridField field)
|
public String processCallout (GridField field)
|
||||||
{
|
{
|
||||||
String callout = field.getCallout();
|
String callout = field.getCallout();
|
||||||
if (callout.length() == 0)
|
if (callout.length() == 0)
|
||||||
|
@ -2383,6 +2395,10 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
while (st.hasMoreTokens()) // for each callout
|
while (st.hasMoreTokens()) // for each callout
|
||||||
{
|
{
|
||||||
String cmd = st.nextToken().trim();
|
String cmd = st.nextToken().trim();
|
||||||
|
|
||||||
|
//detect infinite loop
|
||||||
|
if (activeCallouts.contains(cmd)) continue;
|
||||||
|
|
||||||
Callout call = null;
|
Callout call = null;
|
||||||
String method = null;
|
String method = null;
|
||||||
int methodStart = cmd.lastIndexOf('.');
|
int methodStart = cmd.lastIndexOf('.');
|
||||||
|
@ -2407,6 +2423,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
String retValue = "";
|
String retValue = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
activeCallouts.add(cmd);
|
||||||
retValue = call.start(m_vo.ctx, method, m_vo.WindowNo, this, field, value, oldValue);
|
retValue = call.start(m_vo.ctx, method, m_vo.WindowNo, this, field, value, oldValue);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -2415,6 +2432,11 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
retValue = "Callout Invalid: " + e.toString();
|
retValue = "Callout Invalid: " + e.toString();
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
activeCallouts.remove(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
if (!retValue.equals("")) // interrupt on first error
|
if (!retValue.equals("")) // interrupt on first error
|
||||||
{
|
{
|
||||||
log.severe (retValue);
|
log.severe (retValue);
|
||||||
|
|
Loading…
Reference in New Issue