/** * Add a key for a session Id. * * @param sessionId Crypto session Id. * @param key Response data from the server. */ @CalledByNative private void addKey(String sessionId, byte[] key) { if (mSessionId == null || !mSessionId.equals(sessionId)) { return; } try { final byte[] session = sessionId.getBytes("UTF-8"); try { mMediaDrm.provideKeyResponse(session, key); } catch (java.lang.IllegalStateException e) { // This is not really an exception. Some error code are incorrectly // reported as an exception. // TODO(qinmin): remove this exception catch when b/10495563 is fixed. Log.e( TAG, "Exception intentionally caught when calling provideKeyResponse() " + e.toString()); } mHandler.post( new Runnable() { public void run() { nativeOnKeyAdded(mNativeMediaDrmBridge, mSessionId); } }); return; } catch (android.media.NotProvisionedException e) { Log.e(TAG, "failed to provide key response " + e.toString()); } catch (android.media.DeniedByServerException e) { Log.e(TAG, "failed to provide key response " + e.toString()); } catch (java.io.UnsupportedEncodingException e) { Log.e(TAG, "failed to provide key response " + e.toString()); } onKeyError(); }
@Test public void addFooterView_ShouldThrowIfAdapterIsAlreadySet() throws Exception { listView.setAdapter(new CountingAdapter(1)); try { listView.addFooterView(new View(null)); fail(); } catch (java.lang.IllegalStateException exception) { assertThat( exception.getMessage(), equalTo("Cannot add footer view to list -- setAdapter has already been called")); } }
/** * Write the String by either using the {@link PrintWriter} or {@link java.io.OutputStream}. The * decision is based on the request attribute {@link ApplicationConfig#PROPERTY_USE_STREAM} * * @param data the String to write */ public AtmosphereResponse write(String data) { boolean isUsingStream = (Boolean) request().getAttribute(PROPERTY_USE_STREAM); try { if (isUsingStream) { try { response.getOutputStream().write(data.getBytes(getCharacterEncoding())); } catch (java.lang.IllegalStateException ex) { ex.printStackTrace(); } } else { response.getWriter().write(data); } } catch (IOException e) { logger.trace("", e); } return this; }
@Override public HttpSession getSession(boolean create) { if (b.webSocketFakeSession != null) { return b.webSocketFakeSession; } if (resource() != null) { // UGLY, but we need to prevent looping here. HttpSession session = AtmosphereResourceImpl.class.cast(resource()).session; try { if (session != null) { // check if session is valid (isNew() will throw if not) session.isNew(); return session; } } catch (IllegalStateException e) { // session has been invalidated } } try { return b.request.getSession(create); } catch (java.lang.IllegalStateException ex) { // Jetty if (ex.getMessage() != null && ex.getMessage().equals("No SessionManager")) { return null; } throw ex; } catch (NullPointerException ex) { // GLASSFISH http://java.net/jira/browse/GLASSFISH-18856 return b.request.getSession(create); } catch (RuntimeException ex) { // https://github.com/Atmosphere/atmosphere/issues/1974 logger.trace("", ex); if (ex.getMessage() != null && ex.getMessage().contains("SESN0007E")) { return null; } throw ex; } }