Skip to content

Commit b7cfe6f

Browse files
committed
Added recursion check in the getServiceResponse() method in the WebService class
git-svn-id: svn://192.168.0.80/JavaXT/javaxt-express@1485 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent 8ee406b commit b7cfe6f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/javaxt/express/WebService.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ public ServiceResponse getServiceResponse(ServiceRequest request, Database datab
101101
if (params.length>0){
102102
if (ServiceRequest.class.isAssignableFrom(params[0])){
103103

104+
105+
//Check whether the method accepts a ServiceRequest
106+
//or ServiceRequest + Database as inputs
104107
Object[] inputs = null;
105108
if (params.length==1){
106109
inputs = new Object[]{request};
@@ -112,6 +115,23 @@ else if (params.length==2){
112115
}
113116

114117
if (inputs!=null){
118+
119+
120+
//Ensure that we don't want to invoke this function!
121+
//For example, the caller might want to call
122+
//super.getServiceResponse(request, database);
123+
//If so, we would end up in a recursion causing a
124+
//stack overflow. Instead of calling getServiceResponse()
125+
//let's just flow down to the CRUD handlers below.
126+
StackTraceElement[] stackTrace = new Exception().getStackTrace();
127+
StackTraceElement el = stackTrace[1];
128+
if (m.getName().equals(el.getMethodName())){
129+
break;
130+
}
131+
132+
133+
//If we're still here, call the requested method
134+
//and return the response
115135
try{
116136
m.setAccessible(true);
117137
return (ServiceResponse) m.invoke(this, inputs);

0 commit comments

Comments
 (0)