Example usage for java.lang RuntimeException toString

List of usage examples for java.lang RuntimeException toString

Introduction

In this page you can find the example usage for java.lang RuntimeException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.apache.sling.discovery.impl.topology.connector.TopologyConnectorClient.java

/** ping the server and pass the announcements between the two **/
void ping(final boolean force) {
    if (autoStopped) {
        // then we suppress any further pings!
        logger.debug("ping: autoStopped=true, hence suppressing any further pings.");
        return;/*w  w  w  . ja v  a  2s  . c  om*/
    }
    if (force) {
        backoffPeriodEnd = -1;
    } else if (backoffPeriodEnd > 0) {
        if (System.currentTimeMillis() < backoffPeriodEnd) {
            logger.debug("ping: not issueing a heartbeat due to backoff instruction from peer.");
            return;
        } else {
            logger.debug("ping: backoff period ended, issuing another ping now.");
        }
    }
    final String uri = connectorUrl.toString() + "." + clusterViewService.getSlingId() + ".json";
    if (logger.isDebugEnabled()) {
        logger.debug("ping: connectorUrl=" + connectorUrl + ", complete uri=" + uri);
    }
    HttpClient httpClient = new HttpClient();
    final PutMethod method = new PutMethod(uri);
    Announcement resultingAnnouncement = null;
    try {
        String userInfo = connectorUrl.getUserInfo();
        if (userInfo != null) {
            Credentials c = new UsernamePasswordCredentials(userInfo);
            httpClient.getState()
                    .setCredentials(new AuthScope(method.getURI().getHost(), method.getURI().getPort()), c);
        }

        Announcement topologyAnnouncement = new Announcement(clusterViewService.getSlingId());
        topologyAnnouncement.setServerInfo(serverInfo);
        final ClusterView clusterView = clusterViewService.getClusterView();
        topologyAnnouncement.setLocalCluster(clusterView);
        if (force) {
            logger.debug("ping: sending a resetBackoff");
            topologyAnnouncement.setResetBackoff(true);
        }
        announcementRegistry.addAllExcept(topologyAnnouncement, clusterView, new AnnouncementFilter() {

            public boolean accept(final String receivingSlingId, final Announcement announcement) {
                // filter out announcements that are of old cluster instances
                // which I dont really have in my cluster view at the moment
                final Iterator<InstanceDescription> it = clusterViewService.getClusterView().getInstances()
                        .iterator();
                while (it.hasNext()) {
                    final InstanceDescription instance = it.next();
                    if (instance.getSlingId().equals(receivingSlingId)) {
                        // then I have the receiving instance in my cluster view
                        // all fine then
                        return true;
                    }
                }
                // looks like I dont have the receiving instance in my cluster view
                // then I should also not propagate that announcement anywhere
                return false;
            }
        });
        final String p = requestValidator.encodeMessage(topologyAnnouncement.asJSON());

        if (logger.isDebugEnabled()) {
            logger.debug("ping: topologyAnnouncement json is: " + p);
        }
        requestValidator.trustMessage(method, p);
        if (config.isGzipConnectorRequestsEnabled()) {
            // tell the server that the content is gzipped:
            method.addRequestHeader("Content-Encoding", "gzip");
            // and gzip the body:
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final GZIPOutputStream gzipOut = new GZIPOutputStream(baos);
            gzipOut.write(p.getBytes("UTF-8"));
            gzipOut.close();
            final byte[] gzippedEncodedJson = baos.toByteArray();
            method.setRequestEntity(new ByteArrayRequestEntity(gzippedEncodedJson, "application/json"));
            lastRequestEncoding = "gzip";
        } else {
            // otherwise plaintext:
            method.setRequestEntity(new StringRequestEntity(p, "application/json", "UTF-8"));
            lastRequestEncoding = "plaintext";
        }
        // independent of request-gzipping, we do accept the response to be gzipped,
        // so indicate this to the server:
        method.addRequestHeader("Accept-Encoding", "gzip");
        DefaultHttpMethodRetryHandler retryhandler = new DefaultHttpMethodRetryHandler(0, false);
        httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler);
        httpClient.getHttpConnectionManager().getParams()
                .setConnectionTimeout(1000 * config.getConnectionTimeout());
        httpClient.getHttpConnectionManager().getParams().setSoTimeout(1000 * config.getSoTimeout());
        method.getParams().setSoTimeout(1000 * config.getSoTimeout());
        httpClient.executeMethod(method);
        if (logger.isDebugEnabled()) {
            logger.debug("ping: done. code=" + method.getStatusCode() + " - " + method.getStatusText());
        }
        lastStatusCode = method.getStatusCode();
        lastResponseEncoding = null;
        if (method.getStatusCode() == HttpServletResponse.SC_OK) {
            final Header contentEncoding = method.getResponseHeader("Content-Encoding");
            if (contentEncoding != null && contentEncoding.getValue() != null
                    && contentEncoding.getValue().contains("gzip")) {
                lastResponseEncoding = "gzip";
            } else {
                lastResponseEncoding = "plaintext";
            }
            String responseBody = requestValidator.decodeMessage(method); // limiting to 16MB, should be way enough
            if (logger.isDebugEnabled()) {
                logger.debug("ping: response body=" + responseBody);
            }
            if (responseBody != null && responseBody.length() > 0) {
                Announcement inheritedAnnouncement = Announcement.fromJSON(responseBody);
                final long backoffInterval = inheritedAnnouncement.getBackoffInterval();
                if (backoffInterval > 0) {
                    // then reset the backoffPeriodEnd:

                    /* minus 1 sec to avoid slipping the interval by a few millis */
                    this.backoffPeriodEnd = System.currentTimeMillis() + (1000 * backoffInterval) - 1000;
                    logger.debug("ping: servlet instructed to backoff: backoffInterval=" + backoffInterval
                            + ", resulting in period end of " + new Date(backoffPeriodEnd));
                } else {
                    logger.debug("ping: servlet did not instruct any backoff-ing at this stage");
                    this.backoffPeriodEnd = -1;
                }
                if (inheritedAnnouncement.isLoop()) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(
                                "ping: connector response indicated a loop detected. not registering this announcement from "
                                        + inheritedAnnouncement.getOwnerId());
                    }
                    if (inheritedAnnouncement.getOwnerId().equals(clusterViewService.getSlingId())) {
                        // SLING-3316 : local-loop detected. Check config to see if we should stop this connector

                        if (config.isAutoStopLocalLoopEnabled()) {
                            inheritedAnnouncement = null; // results in connected -> false and representsloop -> true
                            autoStopped = true; // results in isAutoStopped -> true
                        }
                    }
                } else {
                    inheritedAnnouncement.setInherited(true);
                    if (announcementRegistry.registerAnnouncement(inheritedAnnouncement) == -1) {
                        if (logger.isDebugEnabled()) {
                            logger.debug(
                                    "ping: connector response is from an instance which I already see in my topology"
                                            + inheritedAnnouncement);
                        }
                        statusDetails = "receiving side is seeing me via another path (connector or cluster) already (loop)";
                        return;
                    }
                }
                resultingAnnouncement = inheritedAnnouncement;
                statusDetails = null;
            } else {
                statusDetails = "no response body received";
            }
        } else {
            statusDetails = "got HTTP Status-Code: " + lastStatusCode;
        }
        // SLING-2882 : reset suppressPingWarnings_ flag in success case
        suppressPingWarnings_ = false;
    } catch (URIException e) {
        logger.warn("ping: Got URIException: " + e + ", uri=" + uri);
        statusDetails = e.toString();
    } catch (IOException e) {
        // SLING-2882 : set/check the suppressPingWarnings_ flag
        if (suppressPingWarnings_) {
            if (logger.isDebugEnabled()) {
                logger.debug("ping: got IOException: " + e + ", uri=" + uri);
            }
        } else {
            suppressPingWarnings_ = true;
            logger.warn("ping: got IOException [suppressing further warns]: " + e + ", uri=" + uri);
        }
        statusDetails = e.toString();
    } catch (JSONException e) {
        logger.warn("ping: got JSONException: " + e);
        statusDetails = e.toString();
    } catch (RuntimeException re) {
        logger.warn("ping: got RuntimeException: " + re, re);
        statusDetails = re.toString();
    } finally {
        method.releaseConnection();
        lastInheritedAnnouncement = resultingAnnouncement;
        lastPingedAt = System.currentTimeMillis();
    }
}

From source file:myfightinglayoutbugs.FightingLayoutBugs.java

/**
 * Runs all registered {@link LayoutBugDetector}s. Before you call this method, you might:<ul>
 * <li>register new detectors via {@link #enable},</li>
 * <li>remove unwanted detectors via {@link #disable},</li>
 * <li>configure a registered detector via {@link #configure},</li>
 * <li>configure the {@link TextDetector} to be used via {@link #setTextDetector},</li>
 * <li>configure the {@link EdgeDetector} to be used via {@link #setEdgeDetector}.</li>
 * </ul>//from  w  w  w  . j  a  va  2s . c o  m
 */
public Collection<LayoutBug> findLayoutBugsIn(@Nonnull WebPage webPage) {
    if (webPage == null) {
        throw new IllegalArgumentException("Method parameter webPage must not be null.");
    }
    if (_debugMode) {
        setLogLevelToDebug();
        registerDebugListener();
    }
    try {
        TextDetector textDetector = (_textDetector == null ? new AnimationAwareTextDetector() : _textDetector);
        EdgeDetector edgeDetector = (_edgeDetector == null ? new SimpleEdgeDetector() : _edgeDetector);
        try {
            LOG.debug("Analyzing " + webPage.getUrl() + " ...");
            webPage.setTextDetector(textDetector);
            webPage.setEdgeDetector(edgeDetector);
            final Collection<LayoutBug> result = new ArrayList<LayoutBug>();
            for (LayoutBugDetector detector : _detectors) {
                detector.setScreenshotDir(screenshotDir);
                LOG.debug("Running " + detector.getClass().getSimpleName() + " ...");
                result.addAll(detector.findLayoutBugsIn(webPage));
            }
            // TODO: If layout bugs have been detected, LOG.info(diagnostic info + further instrcutions)
            return result;
        } catch (RuntimeException e) {
            String url = null;
            try {
                url = webPage.getUrl().toString();
            } catch (Exception ignored) {
            }
            StringBuilder sb = new StringBuilder();
            sb.append("Failed to analyze ").append(url == null ? "given WebPage" : url).append(" -- ")
                    .append(e.toString()).append("\n");
            if (_debugMode) {
                sb.append(
                        "If you want support (or want to support FLB) you can send an email to fighting-layout-bugs@googlegroups.com with the following information:\n");
                sb.append("    - Your code.\n");
                sb.append("    - All logged output.\n");
                sb.append("    - All screenshot files (you might want to pack those into an zip archive).\n");
                sb.append("TextDetector: ").append(textDetector.getClass().getName()).append("\n");
                sb.append("EdgeDetector: ").append(edgeDetector.getClass().getName()).append("\n");
                sb.append(DebugHelper.getDiagnosticInfo(webPage.getDriver()));
                // TODO: We should create the zip file here ourselves.
            } else {
                sb.append(
                        "If you call FightingLayoutBugs.enableDebugMode() before you call FightingLayoutBugs.findLayoutBugsIn(...) you can get more information.");
            }
            String errorMessage = sb.toString();
            LOG.error(errorMessage);
            throw new RuntimeException(errorMessage, e);
        }
    } finally {
        for (Runnable runnable : _runAfterAnalysis) {
            try {
                runnable.run();
            } catch (RuntimeException e) {
                LOG.warn(runnable + " failed.", e);
            }
        }
    }
}

From source file:com.orchestra.portale.controller.EditPoiController.java

@RequestMapping(value = "/editpoi", params = "name")
public ModelAndView editPoi(@RequestParam(value = "name") String name) {
    ModelAndView model = new ModelAndView("editform");
    try {/*ww w . j a va 2s . c o  m*/
        CompletePOI poi = pm.findOneCompletePoiByName(name);
        model.addObject("nome", poi.getName());
        model.addObject("loc", poi.getLocation());
        model.addObject("cat", poi.getCategories());
        model.addObject("id", poi.getId());
        model.addObject("shortD", poi.getShortDescription());
        model.addObject("addr", poi.getAddress());
        model.addObject("visibility", poi.getVisibility());

        for (AbstractPoiComponent comp : poi.getComponents()) {

            //associazione delle componenti al model tramite lo slug
            String slug = comp.slug();
            int index = slug.lastIndexOf(".");
            String cname = slug.substring(index + 1).replace("Component", "").toLowerCase();

            try {
                Class c = Class.forName(slug);
                model.addObject(cname, c.cast(comp));
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(PoiViewController.class.getName()).log(Level.SEVERE, null, ex);

            }

        }

        return model;
    } catch (RuntimeException e) {
        ModelAndView model2 = new ModelAndView("errorViewPoi");
        model2.addObject("err", "Errore impossibile trovare il poi: " + e.toString());
        return model2;
    }
}

From source file:org.apache.sling.discovery.base.connectors.ping.TopologyConnectorClient.java

/** ping the server and pass the announcements between the two **/
void ping(final boolean force) {
    if (autoStopped) {
        // then we suppress any further pings!
        logger.debug("ping: autoStopped=true, hence suppressing any further pings.");
        return;//from   www.  j a va 2s.  c  o m
    }
    if (force) {
        backoffPeriodEnd = -1;
    } else if (backoffPeriodEnd > 0) {
        if (System.currentTimeMillis() < backoffPeriodEnd) {
            logger.debug("ping: not issueing a heartbeat due to backoff instruction from peer.");
            return;
        } else {
            logger.debug("ping: backoff period ended, issuing another ping now.");
        }
    }
    final String uri = connectorUrl.toString() + "." + clusterViewService.getSlingId() + ".json";
    if (logger.isDebugEnabled()) {
        logger.debug("ping: connectorUrl=" + connectorUrl + ", complete uri=" + uri);
    }
    final HttpClientContext clientContext = HttpClientContext.create();
    final CloseableHttpClient httpClient = createHttpClient();
    final HttpPut putRequest = new HttpPut(uri);

    // setting the connection timeout (idle connection, configured in seconds)
    putRequest.setConfig(
            RequestConfig.custom().setConnectTimeout(1000 * config.getSocketConnectTimeout()).build());

    Announcement resultingAnnouncement = null;
    try {
        String userInfo = connectorUrl.getUserInfo();
        if (userInfo != null) {
            Credentials c = new UsernamePasswordCredentials(userInfo);
            clientContext.getCredentialsProvider().setCredentials(
                    new AuthScope(putRequest.getURI().getHost(), putRequest.getURI().getPort()), c);
        }

        Announcement topologyAnnouncement = new Announcement(clusterViewService.getSlingId());
        topologyAnnouncement.setServerInfo(serverInfo);
        final ClusterView clusterView;
        try {
            clusterView = clusterViewService.getLocalClusterView();
        } catch (UndefinedClusterViewException e) {
            // SLING-5030 : then we cannot ping
            logger.warn("ping: no clusterView available at the moment, cannot ping others now: " + e);
            return;
        }
        topologyAnnouncement.setLocalCluster(clusterView);
        if (force) {
            logger.debug("ping: sending a resetBackoff");
            topologyAnnouncement.setResetBackoff(true);
        }
        announcementRegistry.addAllExcept(topologyAnnouncement, clusterView, new AnnouncementFilter() {

            public boolean accept(final String receivingSlingId, final Announcement announcement) {
                // filter out announcements that are of old cluster instances
                // which I dont really have in my cluster view at the moment
                final Iterator<InstanceDescription> it = clusterView.getInstances().iterator();
                while (it.hasNext()) {
                    final InstanceDescription instance = it.next();
                    if (instance.getSlingId().equals(receivingSlingId)) {
                        // then I have the receiving instance in my cluster view
                        // all fine then
                        return true;
                    }
                }
                // looks like I dont have the receiving instance in my cluster view
                // then I should also not propagate that announcement anywhere
                return false;
            }
        });
        final String p = requestValidator.encodeMessage(topologyAnnouncement.asJSON());

        if (logger.isDebugEnabled()) {
            logger.debug("ping: topologyAnnouncement json is: " + p);
        }
        requestValidator.trustMessage(putRequest, p);
        if (config.isGzipConnectorRequestsEnabled()) {
            // tell the server that the content is gzipped:
            putRequest.addHeader("Content-Encoding", "gzip");
            // and gzip the body:
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final GZIPOutputStream gzipOut = new GZIPOutputStream(baos);
            gzipOut.write(p.getBytes("UTF-8"));
            gzipOut.close();
            final byte[] gzippedEncodedJson = baos.toByteArray();
            putRequest.setEntity(new ByteArrayEntity(gzippedEncodedJson, ContentType.APPLICATION_JSON));
            lastRequestEncoding = "gzip";
        } else {
            // otherwise plaintext:
            final StringEntity plaintext = new StringEntity(p, "UTF-8");
            plaintext.setContentType(ContentType.APPLICATION_JSON.getMimeType());
            putRequest.setEntity(plaintext);
            lastRequestEncoding = "plaintext";
        }
        // independent of request-gzipping, we do accept the response to be gzipped,
        // so indicate this to the server:
        putRequest.addHeader("Accept-Encoding", "gzip");
        final CloseableHttpResponse response = httpClient.execute(putRequest, clientContext);
        if (logger.isDebugEnabled()) {
            logger.debug("ping: done. code=" + response.getStatusLine().getStatusCode() + " - "
                    + response.getStatusLine().getReasonPhrase());
        }
        lastStatusCode = response.getStatusLine().getStatusCode();
        lastResponseEncoding = null;
        if (response.getStatusLine().getStatusCode() == HttpServletResponse.SC_OK) {
            final Header contentEncoding = response.getFirstHeader("Content-Encoding");
            if (contentEncoding != null && contentEncoding.getValue() != null
                    && contentEncoding.getValue().contains("gzip")) {
                lastResponseEncoding = "gzip";
            } else {
                lastResponseEncoding = "plaintext";
            }
            final String responseBody = requestValidator.decodeMessage(putRequest.getURI().getPath(), response); // limiting to 16MB, should be way enough
            if (logger.isDebugEnabled()) {
                logger.debug("ping: response body=" + responseBody);
            }
            if (responseBody != null && responseBody.length() > 0) {
                Announcement inheritedAnnouncement = Announcement.fromJSON(responseBody);
                final long backoffInterval = inheritedAnnouncement.getBackoffInterval();
                if (backoffInterval > 0) {
                    // then reset the backoffPeriodEnd:

                    /* minus 1 sec to avoid slipping the interval by a few millis */
                    this.backoffPeriodEnd = System.currentTimeMillis() + (1000 * backoffInterval) - 1000;
                    logger.debug("ping: servlet instructed to backoff: backoffInterval=" + backoffInterval
                            + ", resulting in period end of " + new Date(backoffPeriodEnd));
                } else {
                    logger.debug("ping: servlet did not instruct any backoff-ing at this stage");
                    this.backoffPeriodEnd = -1;
                }
                if (inheritedAnnouncement.isLoop()) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(
                                "ping: connector response indicated a loop detected. not registering this announcement from "
                                        + inheritedAnnouncement.getOwnerId());
                    }
                    if (inheritedAnnouncement.getOwnerId().equals(clusterViewService.getSlingId())) {
                        // SLING-3316 : local-loop detected. Check config to see if we should stop this connector

                        if (config.isAutoStopLocalLoopEnabled()) {
                            inheritedAnnouncement = null; // results in connected -> false and representsloop -> true
                            autoStopped = true; // results in isAutoStopped -> true
                        }
                    }
                } else {
                    inheritedAnnouncement.setInherited(true);
                    if (announcementRegistry.registerAnnouncement(inheritedAnnouncement) == -1) {
                        if (logger.isDebugEnabled()) {
                            logger.debug(
                                    "ping: connector response is from an instance which I already see in my topology"
                                            + inheritedAnnouncement);
                        }
                        statusDetails = "receiving side is seeing me via another path (connector or cluster) already (loop)";
                        return;
                    }
                }
                resultingAnnouncement = inheritedAnnouncement;
                statusDetails = null;
            } else {
                statusDetails = "no response body received";
            }
        } else {
            statusDetails = "got HTTP Status-Code: " + lastStatusCode;
        }
        // SLING-2882 : reset suppressPingWarnings_ flag in success case
        suppressPingWarnings_ = false;
    } catch (IOException e) {
        // SLING-2882 : set/check the suppressPingWarnings_ flag
        if (suppressPingWarnings_) {
            if (logger.isDebugEnabled()) {
                logger.debug("ping: got IOException: " + e + ", uri=" + uri);
            }
        } else {
            suppressPingWarnings_ = true;
            logger.warn("ping: got IOException [suppressing further warns]: " + e + ", uri=" + uri);
        }
        statusDetails = e.toString();
    } catch (JSONException e) {
        logger.warn("ping: got JSONException: " + e);
        statusDetails = e.toString();
    } catch (RuntimeException re) {
        logger.warn("ping: got RuntimeException: " + re, re);
        statusDetails = re.toString();
    } finally {
        putRequest.releaseConnection();
        lastInheritedAnnouncement = resultingAnnouncement;
        lastPingedAt = System.currentTimeMillis();
        try {
            httpClient.close();
        } catch (IOException e) {
            logger.error("disconnect: could not close httpClient: " + e, e);
        }
    }
}

From source file:com.googlecode.fightinglayoutbugs.FightingLayoutBugs.java

/**
 * Runs all registered {@link LayoutBugDetector}s. Before you call this method, you might:<ul>
 * <li>register new detectors via {@link #enable},</li>
 * <li>remove unwanted detectors via {@link #disable},</li>
 * <li>configure a registered detector via {@link #configure},</li>
 * <li>configure the {@link TextDetector} to be used via {@link #setTextDetector},</li>
 * <li>configure the {@link EdgeDetector} to be used via {@link #setEdgeDetector}.</li>
 * </ul>/*from  w w  w. j  a v a 2 s.  co  m*/
 */
public Collection<LayoutBug> findLayoutBugsIn(@Nonnull WebPage webPage) {
    if (webPage == null) {
        throw new IllegalArgumentException("Method parameter webPage must not be null.");
    }
    if (_debugMode) {
        setLogLevelToDebug();
        registerDebugListener();
    }
    try {
        TextDetector textDetector = (_textDetector == null ? new AnimationAwareTextDetector() : _textDetector);
        EdgeDetector edgeDetector = (_edgeDetector == null ? new SimpleEdgeDetector() : _edgeDetector);
        try {
            LOG.debug("Analyzing " + webPage.getUrl() + " ...");
            webPage.setTextDetector(textDetector);
            webPage.setEdgeDetector(edgeDetector);
            final Collection<LayoutBug> result = new ArrayList<LayoutBug>();
            for (LayoutBugDetector detector : _detectors) {
                detector.setScreenshotDir(screenshotDir);
                LOG.debug("Running " + detector.getClass().getSimpleName() + " ...");
                result.addAll(detector.findLayoutBugsIn(webPage));
            }
            if (!result.isEmpty()) {
                StringBuilder sb = new StringBuilder();
                sb.append("Detected layout bug(s) on ").append(webPage.getUrl()).append("\n");
                if (_debugMode) {
                    sb.append(
                            "If there is a false positive, please send an email to fighting-layout-bugs@googlegroups.com with the following information:\n");
                    sb.append("    - your test code,\n");
                    sb.append("    - all logged output, and\n");
                    sb.append("    - all screenshot files located in: ").append(screenshotDir);
                    sb.append("      (You might want to pack those into an zip archive)\n");
                    sb.append("TextDetector: ").append(textDetector.getClass().getName()).append("\n");
                    sb.append("EdgeDetector: ").append(edgeDetector.getClass().getName()).append("\n");
                    sb.append(DebugHelper.getDiagnosticInfo(webPage.getDriver()));
                } else {
                    sb.append(
                            "If you call FightingLayoutBugs.enableDebugMode() before you call FightingLayoutBugs.findLayoutBugsIn(...) you can get more information.");
                }
                LOG.info(sb.toString());
            }
            return result;
        } catch (RuntimeException e) {
            String url = null;
            try {
                url = webPage.getUrl().toString();
            } catch (Exception ignored) {
            }
            StringBuilder sb = new StringBuilder();
            sb.append("Failed to analyze ").append(url == null ? "given WebPage" : url).append(" -- ")
                    .append(e.toString()).append("\n");
            if (_debugMode) {
                sb.append(
                        "If you want support (or want to support FLB) you can send an email to fighting-layout-bugs@googlegroups.com with the following information:\n");
                sb.append("    - your test code,\n");
                sb.append("    - all logged output, and\n");
                sb.append("    - all screenshot files located in: ").append(screenshotDir);
                sb.append("      (You might want to pack those into an zip archive)\n");
                sb.append("TextDetector: ").append(textDetector.getClass().getName()).append("\n");
                sb.append("EdgeDetector: ").append(edgeDetector.getClass().getName()).append("\n");
                sb.append(DebugHelper.getDiagnosticInfo(webPage.getDriver()));
            } else {
                sb.append(
                        "If you call FightingLayoutBugs.enableDebugMode() before you call FightingLayoutBugs.findLayoutBugsIn(...) you can get more information.");
            }
            String errorMessage = sb.toString();
            LOG.error(errorMessage);
            throw new RuntimeException(errorMessage, e);
        }
    } finally {
        for (Runnable runnable : _runAfterAnalysis) {
            try {
                runnable.run();
            } catch (RuntimeException e) {
                LOG.warn(runnable + " failed.", e);
            }
        }
    }
}

From source file:com.streamsets.pipeline.lib.dirspooler.DirectorySpooler.java

public void destroy() {
    running = false;/*from   ww  w .  jav a 2s . c o  m*/
    try {
        if (scheduledExecutor != null) {
            scheduledExecutor.shutdownNow();
            scheduledExecutor = null;
        }
    } catch (RuntimeException ex) {
        LOG.warn("Error during scheduledExecutor.shutdownNow(), {}", ex.toString(), ex);
    }
}

From source file:org.nuxeo.runtime.model.impl.RegistrationInfoImpl.java

public synchronized void activate() {
    if (state != RESOLVED) {
        return;/*from www  . ja  v a 2  s  .c o m*/
    }

    component = createComponentInstance();

    state = ACTIVATING;
    manager.sendEvent(new ComponentEvent(ComponentEvent.ACTIVATING_COMPONENT, this));

    // activate component
    component.activate();
    log.info("Component activated: " + name);

    state = ACTIVATED;
    manager.sendEvent(new ComponentEvent(ComponentEvent.COMPONENT_ACTIVATED, this));

    // register contributed extensions if any
    if (extensions != null) {
        checkExtensions();
        for (Extension xt : extensions) {
            xt.setComponent(component);
            try {
                manager.registerExtension(xt);
            } catch (RuntimeException e) {
                String msg = "Failed to register extension to: " + xt.getTargetComponent() + ", xpoint: "
                        + xt.getExtensionPoint() + " in component: " + xt.getComponent().getName();
                log.error(msg, e);
                msg += " (" + e.toString() + ')';
                Framework.getRuntime().getWarnings().add(msg);
                Framework.handleDevError(e);
            }
        }
    }

    // register pending extensions if any
    List<ComponentName> names = new ArrayList<>(1 + aliases.size());
    names.add(name);
    names.addAll(aliases);
    for (ComponentName n : names) {
        Set<Extension> pendingExt = manager.pendingExtensions.remove(n);
        if (pendingExt == null) {
            continue;
        }
        for (Extension xt : pendingExt) {
            ComponentManagerImpl.loadContributions(this, xt);
            try {
                component.registerExtension(xt);
            } catch (RuntimeException e) {
                String msg = "Failed to register extension to: " + xt.getTargetComponent() + ", xpoint: "
                        + xt.getExtensionPoint() + " in component: " + xt.getComponent().getName();
                log.error(msg, e);
                msg += " (" + e.toString() + ')';
                Framework.getRuntime().getWarnings().add(msg);
                Framework.handleDevError(e);
            }
        }
    }
}

From source file:com.orchestra.portale.controller.EditEventController.java

@RequestMapping(value = "/editevent", params = "name")
public ModelAndView editPoi(@RequestParam(value = "name") String name) {
    ModelAndView model = new ModelAndView("editeventform");
    try {/*from  ww  w.  j a va2 s. c  o m*/
        CompletePOI poi = pm.findOneCompletePoiByName(name);
        model.addObject("nome", poi.getName());
        model.addObject("loc", poi.getLocation());
        model.addObject("cat", poi.getCategories());
        model.addObject("id", poi.getId());
        model.addObject("shortD", poi.getShortDescription());
        model.addObject("addr", poi.getAddress());
        model.addObject("start", poi.getStart_date());
        model.addObject("end", poi.getEnd_date());

        for (AbstractPoiComponent comp : poi.getComponents()) {

            //associazione delle componenti al model tramite lo slug
            String slug = comp.slug();
            int index = slug.lastIndexOf(".");
            String cname = slug.substring(index + 1).replace("Component", "").toLowerCase();

            try {
                Class c = Class.forName(slug);
                model.addObject(cname, c.cast(comp));
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(PoiViewController.class.getName()).log(Level.SEVERE, null, ex);

            }

        }

        return model;
    } catch (RuntimeException e) {
        ModelAndView model2 = new ModelAndView("errorViewPoi");
        model2.addObject("err", "Errore impossibile trovare il poi: " + e.toString());
        return model2;
    }
}

From source file:org.ireland.jnetty.dispatch.servlet.ServletConfigImpl.java

protected RuntimeException error(Throwable e) {
    RuntimeException e1;

    if (_location != null)
        e1 = new RuntimeException(_location + e.getMessage(), e);
    else/*from ww  w .j a  v a 2  s .  co m*/
        e1 = new RuntimeException(e);

    log.warn(e1.toString());

    return e1;
}

From source file:org.lockss.protocol.LcapDatagramComm.java

private void runHandlers(LockssReceivedDatagram ld) throws ProtocolException {
    try {/*from w  w w.  j  a  v a  2 s .c  om*/
        int proto = ld.getProtocol();
        MessageHandler handler;
        if (proto >= 0 && proto < messageHandlers.size()
                && (handler = (MessageHandler) messageHandlers.get(proto)) != null) {
            runHandler(handler, ld);
        } else {
            log.warning("Received message with unregistered protocol: " + proto + " from " + ld.getSender());
        }
    } catch (RuntimeException e) {
        log.warning("Unexpected error in runHandlers", e);
        throw new ProtocolException(e.toString());
    }
}