@Override public Object attempt(Connection cnx) throws Exception { throw new MessageTooLargeException("message is too big"); }
private void sendMessageDirectly(ClientMessage clientMessage) { Message message; try { if (logger.isDebugEnabled()) { logger.debug("{}: Dispatching directly: {}", this, clientMessage); } message = clientMessage.getMessage(getProxy(), true); sendMessage(message); if (logger.isDebugEnabled()) { logger.debug("{}: Dispatched directly: {}", this, clientMessage); } // The exception handling code was modeled after the MessageDispatcher // run method } catch (MessageTooLargeException e) { logger.warn("Message too large to send to client: {}, {}", clientMessage, e.getMessage()); } catch (IOException e) { synchronized (this._stopDispatchingLock) { // Pause or unregister proxy if (!isStopped() && !getProxy().isPaused()) { logger.fatal(String.format("%s : An unexpected Exception occurred", this), e); pauseOrUnregisterProxy(e); } } } catch (Exception e) { if (!isStopped()) { logger.fatal(String.format("%s : An unexpected Exception occurred", this), e); } } }
@Test public void messageLongerThanMaxIntIsRejected() throws Exception { Part mockPart1 = mock(Part.class); when(mockPart1.getLength()).thenReturn(Integer.MAX_VALUE / 2); Part[] parts = new Part[2]; parts[0] = mockPart1; parts[1] = mockPart1; this.message.setParts(parts); try { this.message.send(); fail("expected an exception but none was thrown"); } catch (MessageTooLargeException e) { assertTrue(e.getMessage().contains("exceeds maximum integer value")); } }
@Test public void maxMessageSizeIsRespected() throws Exception { Part mockPart1 = mock(Part.class); when(mockPart1.getLength()).thenReturn(Message.DEFAULT_MAX_MESSAGE_SIZE / 2); Part[] parts = new Part[2]; parts[0] = mockPart1; parts[1] = mockPart1; this.message.setParts(parts); try { this.message.send(); fail("expected an exception but none was thrown"); } catch (MessageTooLargeException e) { assertFalse(e.getMessage().contains("exceeds maximum integer value")); } }
throw new MessageTooLargeException( "Message size (" + (headerLen + totalPartLen) + ") exceeds maximum integer value"); throw new MessageTooLargeException("Message size (" + msgLen + ") exceeds gemfire.client.max-message-size setting (" + this.maxMessageSize + ")");
logger.warn("Message too large to send to client: {}, {}", clientMessage, e.getMessage()); } catch (IOException e) {