Search in sources :

Example 1 with NativeException

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);
    }
}
Also used : RequestTimeoutException(lucee.runtime.exp.RequestTimeoutException) ApplicationException(lucee.runtime.exp.ApplicationException) CFMLFactoryImpl(lucee.runtime.CFMLFactoryImpl) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) PageServletException(lucee.runtime.exp.PageServletException) PageContextImpl(lucee.runtime.PageContextImpl) NativeException(lucee.runtime.exp.NativeException)

Example 2 with NativeException

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
    }
}
Also used : FDSignalException(com.intergral.fusiondebug.server.FDSignalException) ArrayList(java.util.ArrayList) List(java.util.List) NativeException(lucee.runtime.exp.NativeException)

Example 3 with NativeException

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;
}
Also used : IOException(java.io.IOException) NativeException(lucee.runtime.exp.NativeException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 4 with NativeException

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;
}
Also used : PageException(lucee.runtime.exp.PageException) SocketTimeoutException(java.net.SocketTimeoutException) HTTPException(lucee.runtime.exp.HTTPException) NativeException(lucee.runtime.exp.NativeException)

Aggregations

NativeException (lucee.runtime.exp.NativeException)4 FDSignalException (com.intergral.fusiondebug.server.FDSignalException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ServletRequest (javax.servlet.ServletRequest)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 CFMLFactoryImpl (lucee.runtime.CFMLFactoryImpl)1 PageContextImpl (lucee.runtime.PageContextImpl)1 ApplicationException (lucee.runtime.exp.ApplicationException)1 HTTPException (lucee.runtime.exp.HTTPException)1 PageException (lucee.runtime.exp.PageException)1 PageServletException (lucee.runtime.exp.PageServletException)1 RequestTimeoutException (lucee.runtime.exp.RequestTimeoutException)1