Example usage for java.io IOException getClass

List of usage examples for java.io IOException getClass

Introduction

In this page you can find the example usage for java.io IOException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.apache.hadoop.hdfs.TestAvatarVerification.java

@Test
public void testVerificationAddress() throws Exception {
    LOG.info("------------------- test: testVerificationAddress START ----------------");
    TestAvatarVerificationHandler h = new TestAvatarVerificationHandler();
    InjectionHandler.set(h);//from  w  w w.j av a  2 s . c o  m
    MiniAvatarCluster.instantiationRetries = 2;

    conf = new Configuration();
    try {
        cluster = new MiniAvatarCluster(conf, 0, true, null, null);
        fail("Instantiation should not succeed");
    } catch (IOException e) {
        // exception during registration
        assertTrue("Should get remote exception here", e.getClass().equals(RemoteException.class));
    }
}

From source file:com.liferay.ci.portlet.JenkinsIntegrationPortlet.java

protected void buildSeries(RenderRequest request) {
    PortletPreferences portletPreferences = request.getPreferences();

    String portletId = (String) request.getAttribute(WebKeys.PORTLET_ID);

    String jobName = portletPreferences.getValue("jobname", StringPool.BLANK);

    _log.debug("Getting builds for " + jobName);

    String buildsNumber = portletPreferences.getValue("buildsnumber", StringPool.BLANK);

    try {/*from   w  ww . j  ava 2  s .  co  m*/
        int maxBuildNumber = 0;

        if (Validator.isNotNull(buildsNumber)) {
            maxBuildNumber = Integer.parseInt(buildsNumber);

            _log.debug("Max BuildNumber for build: " + maxBuildNumber);
        }

        String jobCacheKey = jobName + StringPool.POUND + buildsNumber;

        if (!_cache.containsKey(portletId, jobCacheKey)) {
            JSONArray testResults = JenkinsConnectUtil.getBuilds(getConnectionParams(portletPreferences),
                    jobName, maxBuildNumber);

            _cache.put(portletId, jobCacheKey, testResults);
        }

        request.setAttribute("TEST_RESULTS", _cache.get(portletId, jobCacheKey));
    } catch (IOException ioe) {
        SessionErrors.add(request, ioe.getClass());

        _log.error("The job was not available", ioe);
    } catch (JSONException e) {
        _log.error("The job is not well-formed", e);
    }
}

From source file:org.jnode.net.ipv4.tftp.TFTPClient.java

private void diagnose(IOException ex, String message) {
    String exMessage = ex.getClass().getSimpleName() + " - " + ex.getLocalizedMessage();
    out.println(message + ": " + exMessage);
}

From source file:com.clustercontrol.snmp.util.RequestSnmp4j.java

/**
 * ?/*from  ww  w. ja v a2  s .c  om*/
 * IP?Hashtable????
 * ????Hashtable??
 */
public boolean polling(String ipAddress, String community, int portNumber, String oidText, int version,
        int timeout, int retries, String securityLevel, String user, String authPassword, String privPassword,
        String authProtocol, String privProtocol) {

    log.debug("polling() start :" + ipAddress.toString());

    //retries?????hinemos????????????1?
    if (--retries < 0) {
        retries = 0;
    }

    Target target = Snmp4jPollerImpl.createTarget(ipAddress, portNumber, version, community, retries, timeout,
            securityLevel, user);

    DefaultPDUFactory factory = new DefaultPDUFactory();
    factory.setPduType(PDU.GET);
    PDU pdu = factory.createPDU(target);

    pdu.add(new VariableBinding(new OID(oidText)));

    Snmp snmp = null;
    try {
        if (version == SnmpConstants.version3) {
            snmp = Snmp4jPollerImpl.getInstance().createV3Snmp(securityLevel, user, authPassword, privPassword,
                    authProtocol, privProtocol);
        } else {
            snmp = Snmp4jPollerImpl.getInstance().getNotV3SnmpFromPool();
        }

        snmp.listen();
        ResponseEvent resp = snmp.get(pdu, target);

        date = HinemosTime.currentTimeMillis();
        PDU respPdu = resp.getResponse();
        if (respPdu == null) {
            log.info("snmpTimeoutError():" + ipAddress + " " + oidText + " polling failed at TimeoutError");
            message = MessageConstant.MESSAGE_COULD_NOT_GET_VALUE.getMessage() + " snmpTimeoutError."
                    + ipAddress + " " + oidText;
            return false;
        }

        if (respPdu.getErrorStatus() != SnmpConstants.SNMP_ERROR_SUCCESS) {
            message = MessageConstant.MESSAGE_COULD_NOT_GET_VALUE.getMessage() + " Error Status:"
                    + respPdu.getErrorStatus();
            return false;
        }

        for (VariableBinding binding : respPdu.getVariableBindings()) {
            Variable var = binding.getVariable();
            if (var instanceof Null) {
                message = MessageConstant.MESSAGE_COULD_NOT_GET_VALUE.getMessage() + " SnmpV2Error. Value:"
                        + binding.toString();
            } else {
                value = var.toString();
                type = binding.getVariable().getSyntax();
            }
            break;
        }
    } catch (IOException e) {
        log.info("polling : class=" + e.getClass().getName() + ", message=" + e.getMessage() + ", ip="
                + ipAddress);
        message = MessageConstant.MESSAGE_COULD_NOT_GET_VALUE.getMessage() + " (" + e.getMessage() + ")";
        return false;
    } finally {
        if (version == SnmpConstants.version3 && snmp != null) {
            try {
                snmp.close();
            } catch (IOException e) {
                log.warn("polling : " + e.getMessage());
            }
        }
    }

    return true;
}

From source file:de.egore911.drilog.tasks.JsonLoadTask.java

@Override
protected String doInBackground(String... params) {
    exceptionMessage = null;//from   w  w w  .  j a  v  a  2  s .  c  om
    String url = (String) params[0];
    try {
        Pair<String, URL> result = HttpUtil.getPlainTextFromUrl(url);
        return result.first;
    } catch (IOException e) {
        Log.e(getClass().getSimpleName(), e.getMessage(), e);
        exceptionMessage = e.getClass().getSimpleName() + ": " + e.getLocalizedMessage();
        return null;
    }
}

From source file:org.pentaho.platform.web.http.api.resources.utils.EscapeUtilsTest.java

License:asdf

@Test
public void testEscapeJson1() {
    final String src = "[\"as<>df\",\"<xxx>\"]";
    final String expect = "[\"as\\u003C\\u003Edf\",\"\\u003Cxxx\\u003E\"]";
    //Check test data
    Assert.assertEquals("data", JSON.toString(JSON.parse(src)), JSON.toString(JSON.parse(expect)));

    String actual = null;//from w ww .  j a v  a 2 s . c  o m
    try {
        actual = EscapeUtils.escapeJson(src);
    } catch (IOException e) {
        e.printStackTrace();
        Assert.fail("Exception is not expected: " + e.getClass().getName() + " " + e.getMessage());
    }
    Assert.assertEquals(expect, actual);
}

From source file:de.tudarmstadt.lt.seg.sentence.RuleSplitter.java

public int getNextCodePoint() {
    try {//  w w w.j a  v a 2s.c om
        return _reader.read();
    } catch (IOException e) {
        System.err.format("%s: %s%n", e.getClass().getName(), e.getMessage());
        return -1;
    }
}

From source file:net.syscrest.clouderamanager.hipchat.HipchatWebhookController.java

@SuppressWarnings("unchecked")
@RequestMapping("/hipchat-webhook")
public Message processMessage(@RequestBody String messagePayload) {

    logger.info("messagePayload = " + messagePayload);

    try {//from ww w. j  ava2  s .c o m
        Map<String, Object> map = mapper.readValue(messagePayload, HashMap.class);

        int roomIdReceived = (Integer) ((Map<String, Object>) ((Map<String, Object>) map.get("item"))
                .get("room")).get("id");

        if (roomIdReceived != whConf.roomId) {
            logger.debug("room id from request = " + roomIdReceived);
            logger.debug("required room id is = " + whConf.roomId);
            logger.warn("room ids does not match, denying command");
            return new Message("Not authorized, roomIds do not match!");
        }

        String message = (String) ((Map<String, Object>) ((Map<String, Object>) map.get("item")).get("message"))
                .get("message");
        logger.info(" message is = " + message);

        String[] messageParts = message.split(" ", -1);

        if (messageParts.length == 2 && messageParts[1].equalsIgnoreCase("help")) {
            List<String> availableCommands = new ArrayList<String>();
            for (BaseMessageHandler handler : handlers) {
                availableCommands.addAll(handler.listAllCommands(apiRoot));
            }
            return new Message("available commands: " + availableCommands.toString());
        }

        for (BaseMessageHandler handler : handlers) {
            Message msg = handler.processMessage(messageParts, apiRoot);
            if (msg != null) {
                return msg;
            }

        }
        logger.warn("message does not match on handler " + message);
        return new Message(BaseMessageHandler.BAD_MESSAGE_RESPONSE);

    } catch (IOException e) {
        logger.error("", e);
        return new Message("unexpected exception while processing message (" + e.getClass().getName() + " - "
                + e.getMessage() + ")");
    }

}

From source file:com.yahoo.gondola.container.ZookeeperRegistryClientTest.java

@Test(dataProvider = "getInputData")
public void testRegister(String testSiteId, String uri, Class expectedException) throws Exception {
    try {/*from ww  w.ja  v  a  2  s .  c om*/
        InetSocketAddress gondolaAddress = new InetSocketAddress(1234);
        String hostId = registryClient.register(testSiteId, gondolaAddress, URI.create(uri));
        RegistryClient.Entry entry = objectMapper.readValue(
                client.getData().forPath(ZookeeperRegistryClient.GONDOLA_HOSTS + "/" + hostId),
                RegistryClient.Entry.class);

        assertNotNull(entry);
        assertEquals(hostId, entry.hostId);
        assertEquals(testSiteId, config.getSiteIdForHost(entry.hostId));
        assertEquals(gondolaAddress, entry.gondolaAddress);
    } catch (IOException e) {
        assertTrue(e.getClass().equals(expectedException));
    }
}

From source file:org.sakaiproject.orm.ibatis.support.AbstractLobTypeHandler.java

/**
 * This implementation delegates to getResultInternal,
 * passing in the LobHandler of this type.
 * @see #getResultInternal//w  w  w  .j  a  v a  2 s  .c om
 */
public final Object getResult(ResultSet rs, int columnIndex) throws SQLException {
    try {
        return getResultInternal(rs, columnIndex, this.lobHandler);
    } catch (IOException ex) {
        throw new SQLException(
                "I/O errors during LOB access: " + ex.getClass().getName() + ": " + ex.getMessage());
    }
}