Example usage for java.lang NullPointerException getMessage

List of usage examples for java.lang NullPointerException getMessage

Introduction

In this page you can find the example usage for java.lang NullPointerException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.elasticsearch.client.RestClientSingleHostTests.java

public void testNullPath() throws IOException {
    for (String method : getHttpMethods()) {
        try {//from   w w w. j  a v a 2  s .co m
            restClient.performRequest(method, null);
            fail("path set to null should fail!");
        } catch (NullPointerException e) {
            assertEquals("path must not be null", e.getMessage());
        }
    }
}

From source file:org.elasticsearch.client.RestClientSingleHostTests.java

public void testNullParams() throws IOException {
    String method = randomHttpMethod(getRandom());
    int statusCode = randomStatusCode(getRandom());
    try {/*from w  w w .ja  v a  2  s . c om*/
        restClient.performRequest(method, "/" + statusCode, (Map<String, String>) null);
        fail("request should have failed");
    } catch (NullPointerException e) {
        assertEquals("params must not be null", e.getMessage());
    }
    try {
        restClient.performRequest(method, "/" + statusCode, null, (HttpEntity) null);
        fail("request should have failed");
    } catch (NullPointerException e) {
        assertEquals("params must not be null", e.getMessage());
    }
}

From source file:org.openo.msb.wrapper.MicroServiceWrapper.java

public synchronized MicroServiceFullInfo updateMicroServiceNode(String serviceName, String version, String ip,
        String port, int ttl) {
    if ("null".equals(version)) {
        version = "";
    }/* www .  j a va  2 s  . co  m*/
    serviceName = serviceName.replace("*", "/");

    if (StringUtils.isBlank(serviceName)) {
        throw new ExtendedNotSupportedException("update MicroService Node FAIL:serviceName  can't be empty");
    }

    if (StringUtils.isNotBlank(version)) {
        if (!RegExpTestUtil.versionRegExpTest(version)) {
            throw new ExtendedNotSupportedException(
                    "update MicroService Node FAIL:version is not a valid  format");
        }
    }

    if (!RegExpTestUtil.ipRegExpTest(ip)) {
        throw new ExtendedNotSupportedException(
                "update MicroService Node FAIL:ip(" + ip + ")is not a valid IP address");
    }

    if (!RegExpTestUtil.portRegExpTest(port)) {
        throw new ExtendedNotSupportedException(
                "update MicroService Node FAIL:port(" + port + ")is not a valid Port address");
    }

    try {

        MicroServiceDB.getInstance().updateMicroServiceNode2Redis(serviceName, version, ip, port, ttl);

        MicroServiceFullInfo newMicroServiceInfo = MicroServiceDB.getInstance()
                .getMicroServiceInstance(serviceName, version, "");

        return newMicroServiceInfo;
    } catch (NullPointerException e) {
        throw new ExtendedNotFoundException(e.getMessage());
    } catch (Exception e) {
        LOGGER.error("update MicroServiceNode throw exception", e);
        throw new ExtendedInternalServerErrorException(e.getMessage());
    }
}

From source file:org.openo.msb.wrapper.MicroServiceWrapper.java

/**
 * @Title updateMicroServiceStatus/*from   w w  w  .j av a2  s.c  o m*/
 * @Description updateMicroServiceStatus
 * @param serviceName
 * @param version
 * @param status
 * @return
 * @return RouteResult
 */

public synchronized MicroServiceFullInfo updateMicroServiceStatus(String serviceName, String version,
        String status) {

    if ("null".equals(version)) {
        version = "";
    }
    serviceName = serviceName.replace("*", "/");

    if (StringUtils.isBlank(serviceName)) {
        throw new ExtendedNotSupportedException("update MicroService status FAIL:serviceName  can't be empty");
    }

    if (StringUtils.isNotBlank(version)) {
        if (!RegExpTestUtil.versionRegExpTest(version)) {
            throw new ExtendedNotSupportedException(
                    "update MicroService status FAIL:version is not a valid  format");
        }
    }

    if (!"0".equals(status) && !"2".equals(status) && !"1".equals(status)) {

        throw new ExtendedNotSupportedException("update MicroService status FAIL:status is wrong");
    }

    try {

        MicroServiceDB.getInstance().updateMicroServiceStatus(serviceName, version, status);

        MicroServiceFullInfo newMicroServiceInfo = MicroServiceDB.getInstance()
                .getMicroServiceInstance(serviceName, version, "");

        // Notify the listeners
        MicroServiceDB.getInstance().noticeUpdateStatusListener(newMicroServiceInfo, status);

        return newMicroServiceInfo;
    } catch (NullPointerException e) {
        throw new ExtendedNotFoundException(e.getMessage());
    } catch (Exception e) {
        LOGGER.error("update MicroServiceNode throw exception", e);
        throw new ExtendedInternalServerErrorException(e.getMessage());
    }

}

From source file:org.csstudio.diirt.util.core.preferences.DIIRTPreferencesTest.java

License:asdf

/**
 * Test method for {@link org.csstudio.diirt.util.core.preferences.DIIRTPreferences#resolvePlatformPath(java.lang.String)}.
 *///from   ww  w . j  a  va 2  s  . com
@Test
public final void testResolvePlatformPath() throws Throwable {

    try {
        DIIRTPreferences.resolvePlatformPath(null);
    } catch (NullPointerException ex) {
        assertEquals("Null 'path'.", ex.getMessage());
    } catch (Throwable ex) {
        throw ex;
    }

    try {
        DIIRTPreferences.resolvePlatformPath("");
    } catch (IllegalArgumentException ex) {
        assertEquals("Empty path.", ex.getMessage());
    } catch (Throwable ex) {
        throw ex;
    }

    try {
        DIIRTPreferences.resolvePlatformPath(" ");
    } catch (IllegalArgumentException ex) {
        assertEquals("Empty path.", ex.getMessage());
    } catch (Throwable ex) {
        throw ex;
    }

    try {
        DIIRTPreferences.resolvePlatformPath("      ");
    } catch (IllegalArgumentException ex) {
        assertEquals("Empty path.", ex.getMessage());
    } catch (Throwable ex) {
        throw ex;
    }

    assertThat(DIIRTPreferences.resolvePlatformPath("@user.home/"), not(startsWith("@user.home")));

    try {
        DIIRTPreferences.resolvePlatformPath("platform:/config/fuffa");
    } catch (MalformedURLException ex) {
        assertEquals("unknown protocol: platform", ex.getMessage());
    } catch (Throwable ex) {
        throw ex;
    }

}

From source file:org.elasticsearch.client.RestClientSingleHostTests.java

public void testNullHeaders() throws IOException {
    String method = randomHttpMethod(getRandom());
    int statusCode = randomStatusCode(getRandom());
    try {/* w  w w .  j  a  v  a  2s.  co m*/
        performRequest(method, "/" + statusCode, (Header[]) null);
        fail("request should have failed");
    } catch (NullPointerException e) {
        assertEquals("request headers must not be null", e.getMessage());
    }
    try {
        performRequest(method, "/" + statusCode, (Header) null);
        fail("request should have failed");
    } catch (NullPointerException e) {
        assertEquals("request header must not be null", e.getMessage());
    }
}

From source file:org.energy_home.jemma.javagal.rest.resources.LocalServicesResource.java

@Post
public void processPost(String body) {

    String epString = (String) getRequest().getAttributes().get(Resources.PARAMETER_EP);

    if (epString == null) {
        // /{ep} not present
        Parameter timeoutParam = getRequest().getResourceRef().getQueryAsForm()
                .getFirst(ResourcePathURIs.TIMEOUT_PARAM);
        if (timeoutParam != null) {
            timeoutString = timeoutParam.getValue().trim();
            try {
                timeout = Long.decode(Resources.HEX_PREFIX + timeoutString);
            } catch (NumberFormatException nfe) {
                Info info = new Info();
                Status _st = new Status();
                _st.setCode((short) GatewayConstants.GENERAL_ERROR);
                _st.setMessage(nfe.getMessage());
                info.setStatus(_st);/*ww w .  j  a  va  2  s  . c  o m*/
                Info.Detail detail = new Info.Detail();
                info.setDetail(detail);
                getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML);
                return;

            }
            // if (timeout < 0 || timeout > 0xffff) {
            if (!Util.isUnsigned32(timeout)) {

                Info info = new Info();
                Status _st = new Status();
                _st.setCode((short) GatewayConstants.GENERAL_ERROR);
                _st.setMessage("Error: optional '" + ResourcePathURIs.TIMEOUT_PARAM
                        + "' parameter's value invalid. You provided: " + timeoutString);
                info.setStatus(_st);
                Info.Detail detail = new Info.Detail();
                info.setDetail(detail);
                getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML);
                return;

            }
        }

        SimpleDescriptor simpleDescriptor;
        try {
            simpleDescriptor = Util.unmarshal(body, SimpleDescriptor.class);
        } catch (Exception jbe) {

            Info info = new Info();
            Status _st = new Status();
            _st.setCode((short) GatewayConstants.GENERAL_ERROR);
            _st.setMessage("Malformed SimpleDesriptor in request");
            info.setStatus(_st);
            Info.Detail detail = new Info.Detail();
            info.setDetail(detail);
            getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML);
            return;

        }

        // Actual Gal call

        try {
            // Gal Manager check
            proxyGalInterface = getRestManager().getClientObjectKey(-1, getClientInfo().getAddress())
                    .getGatewayInterface();

            // ConfigureEndpoint
            short endPoint = proxyGalInterface.configureEndpoint(timeout, simpleDescriptor);
            if (endPoint > 0) {

                Info info = new Info();
                Status _st = new Status();
                _st.setCode((short) GatewayConstants.SUCCESS);
                info.setStatus(_st);
                Info.Detail detail = new Info.Detail();
                detail.setEndpoint(endPoint);
                info.setDetail(detail);
                getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML);
                return;

            } else {

                Info info = new Info();
                Status _st = new Status();
                _st.setCode((short) GatewayConstants.GENERAL_ERROR);
                _st.setMessage("Error in creating end point. Not created.");
                info.setStatus(_st);
                Info.Detail detail = new Info.Detail();
                info.setDetail(detail);
                getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML);
                return;

            }
        } catch (NullPointerException npe) {
            Info info = new Info();
            Status _st = new Status();
            _st.setCode((short) GatewayConstants.GENERAL_ERROR);
            _st.setMessage(npe.getMessage());
            info.setStatus(_st);
            Info.Detail detail = new Info.Detail();
            info.setDetail(detail);
            getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML);
            return;

        } catch (Exception e1) {
            Info info = new Info();
            Status _st = new Status();
            _st.setCode((short) GatewayConstants.GENERAL_ERROR);
            _st.setMessage(e1.getMessage());
            info.setStatus(_st);
            Info.Detail detail = new Info.Detail();
            info.setDetail(detail);
            getResponse().setEntity(Util.marshal(info), MediaType.APPLICATION_XML);
            return;
        }

    }
}

From source file:app.com.vaipo.ContactsFragment.java

private void setUpFirebaseListner(final Context ctx) {
    myFirebaseRef = new Firebase("https://vaipo.firebaseio.com/" + LINK + "/" + appState.getID());
    myFirebaseRef.addValueEventListener(new ValueEventListener() {
        @Override/*from  ww  w .  j  av  a  2s.c om*/
        public void onDataChange(DataSnapshot dataSnapshot) {
            Log.d(TAG, "There are " + dataSnapshot.getChildrenCount() + " values @ " + myFirebaseRef);
            String newSessionId = "-1", newToken = "-1", newApiKey = "-1";
            boolean peerAutoDiscover = false;

            DialMsg dialMsg = null;
            try {
                dialMsg = dataSnapshot.getValue(DialMsg.class);
            } catch (NullPointerException e) {
                return;
            } catch (Exception e) {
                Log.d(TAG, "Oops error ! " + e.getMessage() + e.toString());
                return;
            }
            if (dialMsg == null)
                return;

            if (dialMsg.getState() == DialMsg.END) {
                if (contactEditText != null)
                    contactEditText.setText("");
                Utils.endVaipoCall(ctx);
            } else {
                newSessionId = dialMsg.getSessionId();
                newToken = dialMsg.getToken();
                newApiKey = dialMsg.getApikey();
                peerAutoDiscover = dialMsg.getPeerautodiscover();

                // TBD: Fix this hack!!
                boolean response = dialMsg.getResponse();
                if (response)
                    Utils.sendUserResponse(ctx, response);
            }

            if (!newSessionId.equalsIgnoreCase("-1") && !newToken.equalsIgnoreCase("-1")
                    && !newApiKey.equalsIgnoreCase("-1")) {

                Intent i = new Intent(ctx, BubbleVideoView.class);
                i.putExtra("sessionId", newSessionId);
                i.putExtra("token", newToken);
                i.putExtra("apikey", newApiKey);
                i.putExtra("peerautodiscover", peerAutoDiscover);

                //if (ctx != null)
                //    ctx.startService(i);
                if (newApiKey.equals(OpenTokConfig.API_KEY) && newSessionId.equals(OpenTokConfig.SESSION_ID)
                        && newToken.equals(OpenTokConfig.TOKEN)) {
                    return;
                }
                OpenTokConfig.API_KEY = newApiKey;
                OpenTokConfig.SESSION_ID = newSessionId;
                OpenTokConfig.TOKEN = newToken;

                Utils.startUI(ctx);
            }
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
}

From source file:com.androguide.apkreator.MainActivity.java

@Override
public void setTitle(CharSequence title) {
    try {//from w w  w .  j av  a  2s  .  com
        getSupportActionBar().setTitle(title);
    } catch (NullPointerException e) {
        Log.e("NPE", e.getMessage());
    }
}

From source file:org.mobicents.servlet.restcomm.http.IncomingPhoneNumbersEndpoint.java

protected Response putIncomingPhoneNumber(final String accountSid, final MultivaluedMap<String, String> data,
        PhoneNumberType phoneNumberType, final MediaType responseType) {
    secure(accountsDao.getAccount(accountSid), "RestComm:Create:IncomingPhoneNumbers");
    try {// w  w w .ja va 2 s  .  co m
        validate(data);
    } catch (final NullPointerException exception) {
        return status(BAD_REQUEST).entity(exception.getMessage()).build();
    }
    String number = data.getFirst("PhoneNumber");
    String isSIP = data.getFirst("isSIP");
    // cater to SIP numbers
    if (isSIP == null) {
        try {
            number = e164(number);
        } catch (NumberParseException e) {
        }
    }
    IncomingPhoneNumber incomingPhoneNumber = dao.getIncomingPhoneNumber(number);
    if (incomingPhoneNumber == null) {
        incomingPhoneNumber = createFrom(new Sid(accountSid), data);
        phoneNumberParameters.setPhoneNumberType(phoneNumberType);

        org.mobicents.servlet.restcomm.provisioning.number.api.PhoneNumber phoneNumber = convertIncomingPhoneNumbertoPhoneNumber(
                incomingPhoneNumber);
        boolean hasSuceeded = false;
        if (phoneNumberProvisioningManager != null && isSIP == null) {
            hasSuceeded = phoneNumberProvisioningManager.buyNumber(phoneNumber, phoneNumberParameters);
        } else if (isSIP != null) {
            hasSuceeded = true;
        }
        if (hasSuceeded) {
            if (phoneNumber.getFriendlyName() != null) {
                incomingPhoneNumber.setFriendlyName(phoneNumber.getFriendlyName());
            }
            if (phoneNumber.getPhoneNumber() != null) {
                incomingPhoneNumber.setPhoneNumber(phoneNumber.getPhoneNumber());
            }
            dao.addIncomingPhoneNumber(incomingPhoneNumber);
            if (APPLICATION_JSON_TYPE == responseType) {
                return ok(gson.toJson(incomingPhoneNumber), APPLICATION_JSON).build();
            } else if (APPLICATION_XML_TYPE == responseType) {
                final RestCommResponse response = new RestCommResponse(incomingPhoneNumber);
                return ok(xstream.toXML(response), APPLICATION_XML).build();
            }
        }
    }
    return status(BAD_REQUEST).entity("21452").build();
}