use of lucee.runtime.exp.NativeException in project Lucee by lucee.
the class CFMLEngineImpl method _service.
private void _service(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp, short type) throws ServletException, IOException {
CFMLFactoryImpl factory = (CFMLFactoryImpl) getCFMLFactory(servlet.getServletConfig(), req);
// is Lucee dialect enabled?
if (type == Request.TYPE_LUCEE) {
if (!((ConfigImpl) factory.getConfig()).allowLuceeDialect()) {
try {
PageContextImpl.notSupported();
} catch (ApplicationException e) {
throw new PageServletException(e);
}
}
}
boolean exeReqAsync = exeRequestAsync();
PageContextImpl pc = factory.getPageContextImpl(servlet, req, rsp, null, false, -1, false, !exeReqAsync, false, -1, true, false, false);
try {
Request r = new Request(pc, type);
if (exeReqAsync) {
r.start();
long ended = -1;
do {
SystemUtil.wait(Thread.currentThread(), 1000);
// done?
if (r.isDone()) {
// print.e("mas-done:"+System.currentTimeMillis());
break;
} else // reach request timeout
if (ended == -1 && (pc.getStartTime() + pc.getRequestTimeout()) < System.currentTimeMillis()) {
// print.e("req-time:"+System.currentTimeMillis());
CFMLFactoryImpl.terminate(pc, false);
ended = System.currentTimeMillis();
// break; we do not break here, we give the thread itself the chance to end we need the exception output
} else // the thread itself seem blocked, so we release this thread
if (ended > -1 && ended + 10000 <= System.currentTimeMillis()) {
// print.e("give-up:"+System.currentTimeMillis());
break;
}
} while (true);
} else // run in thread coming from servlet engine
{
try {
Request.exe(pc, type, true, false);
} catch (RequestTimeoutException rte) {
if (rte.getThreadDeath() != null)
throw rte.getThreadDeath();
} catch (NativeException ne) {
if (ne.getCause() instanceof ThreadDeath)
throw (ThreadDeath) ne.getCause();
} catch (ThreadDeath td) {
throw td;
} catch (Throwable t) {
}
}
} finally {
factory.releaseLuceePageContext(pc, !exeReqAsync);
}
}
use of lucee.runtime.exp.NativeException in project Lucee by lucee.
the class FDSignal method signal.
public static void signal(PageException pe, boolean caught) {
try {
String id = pe.hashCode() + ":" + caught;
if (Caster.toString(hash.get(), "").equals(id))
return;
List stack = createExceptionStack(pe);
if (stack.size() > 0) {
FDSignalException se = new FDSignalException();
se.setExceptionStack(stack);
se.setRuntimeExceptionCaughtStatus(caught);
se.setRuntimeExceptionExpression(createRuntimeExceptionExpression(pe));
if (pe instanceof NativeException)
se.setRuntimeExceptionType("native");
else
se.setRuntimeExceptionType(pe.getTypeAsString());
se.setStackTrace(pe.getStackTrace());
hash.set(id);
throw se;
}
} catch (FDSignalException fdse) {
// do nothing - will be processed by JDI and handled by FD
}
}
use of lucee.runtime.exp.NativeException in project Lucee by lucee.
the class ExceptionUtil method toIOException.
public static IOException toIOException(Throwable t) {
rethrowIfNecessary(t);
if (t instanceof IOException)
return (IOException) t;
if (t instanceof InvocationTargetException)
return toIOException(((InvocationTargetException) t).getCause());
if (t instanceof NativeException)
return toIOException(((NativeException) t).getCause());
IOException ioe = new IOException(t.getClass().getName() + ":" + t.getMessage());
ioe.setStackTrace(t.getStackTrace());
return ioe;
}
use of lucee.runtime.exp.NativeException in project Lucee by lucee.
the class HttpGetWithBody method toPageException.
private PageException toPageException(Throwable t, HTTPResponse4Impl rsp) {
if (t instanceof SocketTimeoutException) {
HTTPException he = new HTTPException("408 Request Time-out", "a timeout occurred in tag http", 408, "Time-out", rsp == null ? null : rsp.getURL());
List<StackTraceElement> merged = ArrayUtil.merge(t.getStackTrace(), he.getStackTrace());
StackTraceElement[] traces = new StackTraceElement[merged.size()];
Iterator<StackTraceElement> it = merged.iterator();
int index = 0;
while (it.hasNext()) {
traces[index++] = it.next();
}
he.setStackTrace(traces);
return he;
}
PageException pe = Caster.toPageException(t);
if (pe instanceof NativeException) {
((NativeException) pe).setAdditional(KeyConstants._url, url);
}
return pe;
}
Aggregations