From 7763f0ec9fe09445ba1bf0cfaa057468713c37a7 Mon Sep 17 00:00:00 2001 From: ZafrulLipu Date: Wed, 6 May 2026 15:55:44 +0700 Subject: [PATCH 1/2] migrate decaf Exceptions --- .../tool/commands/CommandSourceGenerator.java | 5 +- .../tool/commands/MessageSourceGenerator.java | 12 +- .../AmqCppMarshallingClassesGenerator.java | 30 +- .../AmqCppMarshallingHeadersGenerator.java | 2 +- .../examples/advisories/AdvisoryConsumer.cpp | 9 +- .../examples/advisories/AdvisoryProducer.cpp | 7 +- .../TempDestinationAdvisoryConsumer.cpp | 31 +- .../ConnectionFactoryMgr.cpp | 4 +- .../examples/stress-test/BrokerMonitor.cpp | 1 - .../src/examples/stress-test/CmsStress.cpp | 1 - .../stress-test/ConnectionFactoryMgr.cpp | 5 +- activemq-cpp/src/main/CMakeLists.txt | 30 +- .../src/main/activemq/cmsutil/CmsTemplate.cpp | 3 +- .../src/main/activemq/cmsutil/CmsTemplate.h | 2 +- .../cmsutil/DynamicDestinationResolver.cpp | 8 +- .../main/activemq/cmsutil/PooledSession.cpp | 6 +- .../commands/ActiveMQBytesMessage.cpp | 300 +------ .../activemq/commands/ActiveMQDestination.cpp | 25 +- .../activemq/commands/ActiveMQMapMessage.cpp | 126 +-- .../activemq/commands/ActiveMQMapMessage.h | 5 +- .../commands/ActiveMQMessageTemplate.h | 59 +- .../commands/ActiveMQObjectMessage.cpp | 3 +- .../commands/ActiveMQStreamMessage.cpp | 294 ++++--- .../activemq/commands/ActiveMQStreamMessage.h | 1 - .../activemq/commands/ActiveMQTextMessage.cpp | 6 +- .../main/activemq/commands/BrokerError.cpp | 8 +- .../src/main/activemq/commands/BrokerId.cpp | 6 +- .../src/main/activemq/commands/BrokerInfo.cpp | 7 +- .../activemq/commands/ConnectionControl.cpp | 7 +- .../activemq/commands/ConnectionError.cpp | 7 +- .../main/activemq/commands/ConnectionId.cpp | 6 +- .../main/activemq/commands/ConnectionInfo.cpp | 7 +- .../activemq/commands/ConsumerControl.cpp | 7 +- .../src/main/activemq/commands/ConsumerId.cpp | 6 +- .../main/activemq/commands/ConsumerInfo.cpp | 7 +- .../main/activemq/commands/ControlCommand.cpp | 7 +- .../activemq/commands/DataArrayResponse.cpp | 7 +- .../main/activemq/commands/DataResponse.cpp | 7 +- .../activemq/commands/DestinationInfo.cpp | 7 +- .../main/activemq/commands/DiscoveryEvent.cpp | 7 +- .../activemq/commands/ExceptionResponse.cpp | 7 +- .../main/activemq/commands/FlushCommand.cpp | 7 +- .../activemq/commands/IntegerResponse.cpp | 7 +- .../activemq/commands/JournalQueueAck.cpp | 7 +- .../activemq/commands/JournalTopicAck.cpp | 7 +- .../main/activemq/commands/JournalTrace.cpp | 7 +- .../activemq/commands/JournalTransaction.cpp | 7 +- .../main/activemq/commands/KeepAliveInfo.cpp | 7 +- .../activemq/commands/LastPartialCommand.cpp | 7 +- .../activemq/commands/LocalTransactionId.cpp | 6 +- .../src/main/activemq/commands/Message.cpp | 21 +- .../src/main/activemq/commands/MessageAck.cpp | 7 +- .../activemq/commands/MessageDispatch.cpp | 7 +- .../commands/MessageDispatchNotification.cpp | 7 +- .../src/main/activemq/commands/MessageId.cpp | 44 +- .../main/activemq/commands/MessagePull.cpp | 7 +- .../activemq/commands/NetworkBridgeFilter.cpp | 7 +- .../main/activemq/commands/PartialCommand.cpp | 7 +- .../main/activemq/commands/ProducerAck.cpp | 7 +- .../src/main/activemq/commands/ProducerId.cpp | 44 +- .../main/activemq/commands/ProducerInfo.cpp | 7 +- .../src/main/activemq/commands/RemoveInfo.cpp | 7 +- .../commands/RemoveSubscriptionInfo.cpp | 7 +- .../main/activemq/commands/ReplayCommand.cpp | 7 +- .../src/main/activemq/commands/Response.cpp | 7 +- .../src/main/activemq/commands/SessionId.cpp | 6 +- .../main/activemq/commands/SessionInfo.cpp | 7 +- .../main/activemq/commands/ShutdownInfo.cpp | 7 +- .../activemq/commands/SubscriptionInfo.cpp | 7 +- .../main/activemq/commands/TransactionId.cpp | 6 +- .../activemq/commands/TransactionInfo.cpp | 7 +- .../main/activemq/commands/WireFormatInfo.cpp | 21 +- .../activemq/commands/XATransactionId.cpp | 6 +- .../main/activemq/core/ActiveMQConnection.cpp | 226 ++++-- .../main/activemq/core/ActiveMQConnection.h | 16 +- .../core/ActiveMQConnectionFactory.cpp | 12 +- .../main/activemq/core/ActiveMQConsumer.cpp | 1 - .../core/ActiveMQDestinationEvent.cpp | 13 +- .../core/ActiveMQDestinationSource.cpp | 30 +- .../activemq/core/ActiveMQMessageAudit.cpp | 15 +- .../main/activemq/core/ActiveMQProducer.cpp | 2 - .../activemq/core/ActiveMQQueueBrowser.cpp | 3 +- .../main/activemq/core/ActiveMQSession.cpp | 3 - .../activemq/core/ActiveMQSessionExecutor.cpp | 18 +- .../core/ActiveMQTransactionContext.cpp | 83 +- .../core/ActiveMQTransactionContext.h | 6 +- .../main/activemq/core/AdvisoryConsumer.cpp | 26 +- .../main/activemq/core/ConnectionAudit.cpp | 11 +- .../core/FifoMessageDispatchChannel.cpp | 6 +- .../src/main/activemq/core/PrefetchPolicy.h | 5 +- .../src/main/activemq/core/RedeliveryPolicy.h | 5 +- .../core/kernels/ActiveMQConsumerKernel.cpp | 170 ++-- .../core/kernels/ActiveMQConsumerKernel.h | 2 +- .../core/kernels/ActiveMQProducerKernel.cpp | 10 +- .../core/kernels/ActiveMQSessionKernel.cpp | 76 +- .../activemq/exceptions/ActiveMQException.cpp | 8 + .../activemq/exceptions/ActiveMQException.h | 6 + .../exceptions}/BufferUnderflowException.cpp | 80 +- .../exceptions/BufferUnderflowException.h | 76 ++ .../main/activemq/exceptions/ExceptionTypes.h | 401 ++++++++++ .../main/activemq/exceptions/IoCatchMacros.h | 108 +++ .../main/activemq/exceptions/IoExceptions.cpp | 339 ++++++++ .../main/activemq/exceptions/IoExceptions.h | 168 ++++ .../exceptions/StdExceptionCatchMacros.h | 222 ++++++ .../main/activemq/io/LoggingInputStream.cpp | 64 +- .../src/main/activemq/io/LoggingInputStream.h | 1 - .../main/activemq/io/LoggingOutputStream.cpp | 56 +- .../main/activemq/state/ConnectionState.cpp | 8 +- .../activemq/state/ConnectionStateTracker.cpp | 50 +- .../src/main/activemq/state/SessionState.cpp | 6 +- .../main/activemq/state/TransactionState.cpp | 6 +- .../activemq/threads/CompositeTaskRunner.cpp | 1 - .../activemq/threads/DedicatedTaskRunner.cpp | 10 +- .../src/main/activemq/threads/Scheduler.cpp | 41 +- .../activemq/threads/SchedulerTimerTask.cpp | 12 +- .../transport/AbstractTransportFactory.cpp | 19 +- .../transport/AbstractTransportFactory.h | 4 +- .../activemq/transport/FutureResponse.cpp | 29 +- .../main/activemq/transport/FutureResponse.h | 4 +- .../main/activemq/transport/IOTransport.cpp | 185 +++-- .../src/main/activemq/transport/IOTransport.h | 12 +- .../src/main/activemq/transport/Transport.h | 12 +- .../activemq/transport/TransportFilter.cpp | 104 +-- .../activemq/transport/TransportRegistry.cpp | 17 +- .../activemq/transport/TransportRegistry.h | 10 +- .../correlator/ResponseCorrelator.cpp | 93 ++- .../transport/correlator/ResponseCorrelator.h | 2 +- .../discovery/AbstractDiscoveryAgent.cpp | 12 +- .../discovery/DiscoveryAgentRegistry.cpp | 19 +- .../discovery/DiscoveryAgentRegistry.h | 7 +- .../discovery/DiscoveryTransport.cpp | 85 +- .../discovery/http/HttpDiscoveryAgent.cpp | 7 +- .../failover/BackupTransportPool.cpp | 92 ++- .../transport/failover/BackupTransportPool.h | 2 +- .../transport/failover/FailoverTransport.cpp | 207 +++-- .../transport/failover/FailoverTransport.h | 9 +- .../failover/FailoverTransportFactory.cpp | 10 +- .../failover/FailoverTransportListener.cpp | 12 +- .../activemq/transport/failover/URIPool.cpp | 10 +- .../activemq/transport/failover/URIPool.h | 6 +- .../inactivity/InactivityMonitor.cpp | 104 ++- .../transport/inactivity/ReadChecker.cpp | 14 +- .../transport/inactivity/WriteChecker.cpp | 14 +- .../transport/logging/LoggingTransport.cpp | 27 +- .../mock/InternalCommandListener.cpp | 9 +- .../activemq/transport/mock/MockTransport.cpp | 49 +- .../activemq/transport/mock/MockTransport.h | 6 +- .../transport/mock/MockTransportFactory.cpp | 3 +- .../activemq/transport/tcp/SslTransport.cpp | 32 +- .../activemq/transport/tcp/TcpTransport.cpp | 30 +- .../activemq/transport/tcp/TcpTransport.h | 5 +- .../util/ActiveMQMessageTransformation.cpp | 26 +- .../main/activemq/util/AdvisorySupport.cpp | 77 +- .../activemq/util/CMSExceptionSupport.cpp | 72 +- .../main/activemq/util/CMSExceptionSupport.h | 156 +++- .../src/main/activemq/util/IdGenerator.cpp | 11 +- .../main/activemq/util/MarshallingSupport.cpp | 64 +- .../main/activemq/util/MarshallingSupport.h | 14 +- .../src/main/activemq/util/PrimitiveList.cpp | 1 - .../src/main/activemq/util/PrimitiveList.h | 63 +- .../src/main/activemq/util/PrimitiveMap.cpp | 1 - .../src/main/activemq/util/PrimitiveMap.h | 44 +- .../activemq/util/PrimitiveValueConverter.cpp | 40 +- .../activemq/util/PrimitiveValueConverter.h | 11 +- .../main/activemq/util/PrimitiveValueNode.cpp | 32 +- .../main/activemq/util/PrimitiveValueNode.h | 26 +- .../src/main/activemq/util/ServiceStopper.cpp | 21 +- .../src/main/activemq/util/URISupport.cpp | 166 ++-- .../src/main/activemq/util/URISupport.h | 13 +- .../main/activemq/wireformat/MarshalAware.h | 2 +- .../src/main/activemq/wireformat/WireFormat.h | 6 +- .../activemq/wireformat/WireFormatFactory.h | 3 +- .../wireformat/WireFormatRegistry.cpp | 18 +- .../activemq/wireformat/WireFormatRegistry.h | 10 +- .../wireformat/openwire/OpenWireFormat.cpp | 170 ++-- .../wireformat/openwire/OpenWireFormat.h | 9 +- .../openwire/OpenWireFormatFactory.cpp | 14 +- .../openwire/OpenWireFormatFactory.h | 1 - .../openwire/OpenWireFormatNegotiator.cpp | 80 +- .../marshal/BaseDataStreamMarshaller.cpp | 183 ++--- .../marshal/BaseDataStreamMarshaller.h | 22 +- .../openwire/marshal/DataStreamMarshaller.h | 2 +- .../marshal/PrimitiveTypesMarshaller.cpp | 46 +- .../marshal/PrimitiveTypesMarshaller.h | 2 +- .../ActiveMQBlobMessageMarshaller.cpp | 35 +- .../generated/ActiveMQBlobMessageMarshaller.h | 2 +- .../ActiveMQBytesMessageMarshaller.cpp | 35 +- .../ActiveMQBytesMessageMarshaller.h | 2 +- .../ActiveMQDestinationMarshaller.cpp | 35 +- .../generated/ActiveMQDestinationMarshaller.h | 2 +- .../ActiveMQMapMessageMarshaller.cpp | 35 +- .../generated/ActiveMQMapMessageMarshaller.h | 2 +- .../generated/ActiveMQMessageMarshaller.cpp | 35 +- .../generated/ActiveMQMessageMarshaller.h | 2 +- .../ActiveMQObjectMessageMarshaller.cpp | 35 +- .../ActiveMQObjectMessageMarshaller.h | 2 +- .../generated/ActiveMQQueueMarshaller.cpp | 35 +- .../generated/ActiveMQQueueMarshaller.h | 2 +- .../ActiveMQStreamMessageMarshaller.cpp | 35 +- .../ActiveMQStreamMessageMarshaller.h | 2 +- .../ActiveMQTempDestinationMarshaller.cpp | 35 +- .../ActiveMQTempDestinationMarshaller.h | 2 +- .../generated/ActiveMQTempQueueMarshaller.cpp | 35 +- .../generated/ActiveMQTempQueueMarshaller.h | 2 +- .../generated/ActiveMQTempTopicMarshaller.cpp | 35 +- .../generated/ActiveMQTempTopicMarshaller.h | 2 +- .../ActiveMQTextMessageMarshaller.cpp | 35 +- .../generated/ActiveMQTextMessageMarshaller.h | 2 +- .../generated/ActiveMQTopicMarshaller.cpp | 35 +- .../generated/ActiveMQTopicMarshaller.h | 2 +- .../generated/BaseCommandMarshaller.cpp | 35 +- .../marshal/generated/BaseCommandMarshaller.h | 2 +- .../marshal/generated/BrokerIdMarshaller.cpp | 35 +- .../marshal/generated/BrokerIdMarshaller.h | 2 +- .../generated/BrokerInfoMarshaller.cpp | 35 +- .../marshal/generated/BrokerInfoMarshaller.h | 2 +- .../generated/ConnectionControlMarshaller.cpp | 35 +- .../generated/ConnectionControlMarshaller.h | 2 +- .../generated/ConnectionErrorMarshaller.cpp | 35 +- .../generated/ConnectionErrorMarshaller.h | 2 +- .../generated/ConnectionIdMarshaller.cpp | 35 +- .../generated/ConnectionIdMarshaller.h | 2 +- .../generated/ConnectionInfoMarshaller.cpp | 35 +- .../generated/ConnectionInfoMarshaller.h | 2 +- .../generated/ConsumerControlMarshaller.cpp | 35 +- .../generated/ConsumerControlMarshaller.h | 2 +- .../generated/ConsumerIdMarshaller.cpp | 35 +- .../marshal/generated/ConsumerIdMarshaller.h | 2 +- .../generated/ConsumerInfoMarshaller.cpp | 35 +- .../generated/ConsumerInfoMarshaller.h | 2 +- .../generated/ControlCommandMarshaller.cpp | 35 +- .../generated/ControlCommandMarshaller.h | 2 +- .../generated/DataArrayResponseMarshaller.cpp | 35 +- .../generated/DataArrayResponseMarshaller.h | 2 +- .../generated/DataResponseMarshaller.cpp | 35 +- .../generated/DataResponseMarshaller.h | 2 +- .../generated/DestinationInfoMarshaller.cpp | 35 +- .../generated/DestinationInfoMarshaller.h | 2 +- .../generated/DiscoveryEventMarshaller.cpp | 35 +- .../generated/DiscoveryEventMarshaller.h | 2 +- .../generated/ExceptionResponseMarshaller.cpp | 35 +- .../generated/ExceptionResponseMarshaller.h | 2 +- .../generated/FlushCommandMarshaller.cpp | 35 +- .../generated/FlushCommandMarshaller.h | 2 +- .../generated/IntegerResponseMarshaller.cpp | 35 +- .../generated/IntegerResponseMarshaller.h | 2 +- .../generated/JournalQueueAckMarshaller.cpp | 35 +- .../generated/JournalQueueAckMarshaller.h | 2 +- .../generated/JournalTopicAckMarshaller.cpp | 35 +- .../generated/JournalTopicAckMarshaller.h | 2 +- .../generated/JournalTraceMarshaller.cpp | 35 +- .../generated/JournalTraceMarshaller.h | 2 +- .../JournalTransactionMarshaller.cpp | 35 +- .../generated/JournalTransactionMarshaller.h | 2 +- .../generated/KeepAliveInfoMarshaller.cpp | 35 +- .../generated/KeepAliveInfoMarshaller.h | 2 +- .../LastPartialCommandMarshaller.cpp | 35 +- .../generated/LastPartialCommandMarshaller.h | 2 +- .../LocalTransactionIdMarshaller.cpp | 35 +- .../generated/LocalTransactionIdMarshaller.h | 2 +- .../generated/MessageAckMarshaller.cpp | 35 +- .../marshal/generated/MessageAckMarshaller.h | 2 +- .../generated/MessageDispatchMarshaller.cpp | 35 +- .../generated/MessageDispatchMarshaller.h | 2 +- .../MessageDispatchNotificationMarshaller.cpp | 35 +- .../MessageDispatchNotificationMarshaller.h | 2 +- .../marshal/generated/MessageIdMarshaller.cpp | 35 +- .../marshal/generated/MessageIdMarshaller.h | 2 +- .../marshal/generated/MessageMarshaller.cpp | 35 +- .../marshal/generated/MessageMarshaller.h | 2 +- .../generated/MessagePullMarshaller.cpp | 35 +- .../marshal/generated/MessagePullMarshaller.h | 2 +- .../NetworkBridgeFilterMarshaller.cpp | 35 +- .../generated/NetworkBridgeFilterMarshaller.h | 2 +- .../generated/PartialCommandMarshaller.cpp | 35 +- .../generated/PartialCommandMarshaller.h | 2 +- .../generated/ProducerAckMarshaller.cpp | 35 +- .../marshal/generated/ProducerAckMarshaller.h | 2 +- .../generated/ProducerIdMarshaller.cpp | 35 +- .../marshal/generated/ProducerIdMarshaller.h | 2 +- .../generated/ProducerInfoMarshaller.cpp | 35 +- .../generated/ProducerInfoMarshaller.h | 2 +- .../generated/RemoveInfoMarshaller.cpp | 35 +- .../marshal/generated/RemoveInfoMarshaller.h | 2 +- .../RemoveSubscriptionInfoMarshaller.cpp | 35 +- .../RemoveSubscriptionInfoMarshaller.h | 2 +- .../generated/ReplayCommandMarshaller.cpp | 35 +- .../generated/ReplayCommandMarshaller.h | 2 +- .../marshal/generated/ResponseMarshaller.cpp | 35 +- .../marshal/generated/ResponseMarshaller.h | 2 +- .../marshal/generated/SessionIdMarshaller.cpp | 35 +- .../marshal/generated/SessionIdMarshaller.h | 2 +- .../generated/SessionInfoMarshaller.cpp | 35 +- .../marshal/generated/SessionInfoMarshaller.h | 2 +- .../generated/ShutdownInfoMarshaller.cpp | 35 +- .../generated/ShutdownInfoMarshaller.h | 2 +- .../generated/SubscriptionInfoMarshaller.cpp | 35 +- .../generated/SubscriptionInfoMarshaller.h | 2 +- .../generated/TransactionIdMarshaller.cpp | 35 +- .../generated/TransactionIdMarshaller.h | 2 +- .../generated/TransactionInfoMarshaller.cpp | 35 +- .../generated/TransactionInfoMarshaller.h | 2 +- .../generated/WireFormatInfoMarshaller.cpp | 35 +- .../generated/WireFormatInfoMarshaller.h | 2 +- .../generated/XATransactionIdMarshaller.cpp | 35 +- .../generated/XATransactionIdMarshaller.h | 2 +- .../openwire/utils/BooleanStream.cpp | 31 +- .../wireformat/openwire/utils/HexTable.cpp | 50 +- .../wireformat/openwire/utils/HexTable.h | 3 +- .../utils/MessagePropertyInterceptor.cpp | 43 +- .../utils/MessagePropertyInterceptor.h | 4 +- .../stomp/StompCommandConstants.cpp | 1 - .../wireformat/stomp/StompCommandConstants.h | 1 - .../activemq/wireformat/stomp/StompFrame.cpp | 63 +- .../wireformat/stomp/StompWireFormat.cpp | 110 +-- .../wireformat/stomp/StompWireFormat.h | 5 +- activemq-cpp/src/main/cms/BytesMessage.h | 2 +- .../src/main/cms/XAConnectionFactory.h | 1 + .../internal/io/StandardErrorOutputStream.cpp | 29 +- .../decaf/internal/io/StandardInputStream.cpp | 1 - .../internal/io/StandardOutputStream.cpp | 27 +- .../src/main/decaf/internal/net/Network.cpp | 13 +- .../src/main/decaf/internal/net/Network.h | 5 +- .../decaf/internal/net/URIEncoderDecoder.cpp | 23 +- .../src/main/decaf/internal/net/URIHelper.cpp | 8 +- .../internal/net/URLStreamHandlerManager.cpp | 5 +- .../decaf/internal/net/file/FileHandler.cpp | 12 +- .../decaf/internal/net/http/HttpHandler.cpp | 12 +- .../decaf/internal/net/https/HttpsHandler.cpp | 12 +- .../net/ssl/openssl/OpenSSLContextSpi.cpp | 15 +- .../net/ssl/openssl/OpenSSLParameters.cpp | 18 +- .../net/ssl/openssl/OpenSSLServerSocket.cpp | 7 +- .../openssl/OpenSSLServerSocketFactory.cpp | 14 +- .../net/ssl/openssl/OpenSSLSocket.cpp | 97 +-- .../internal/net/ssl/openssl/OpenSSLSocket.h | 9 +- .../net/ssl/openssl/OpenSSLSocketFactory.cpp | 21 +- .../ssl/openssl/OpenSSLSocketInputStream.cpp | 21 +- .../ssl/openssl/OpenSSLSocketOutputStream.cpp | 20 +- .../main/decaf/internal/net/tcp/TcpSocket.cpp | 81 +- .../main/decaf/internal/net/tcp/TcpSocket.h | 11 +- .../internal/net/tcp/TcpSocketInputStream.cpp | 21 +- .../internal/net/tcp/TcpSocketInputStream.h | 2 - .../net/tcp/TcpSocketOutputStream.cpp | 17 +- .../main/decaf/internal/nio/BufferFactory.cpp | 347 ++++++-- .../main/decaf/internal/nio/BufferFactory.h | 44 +- .../decaf/internal/nio/ByteArrayBuffer.cpp | 684 ++++++++++++---- .../main/decaf/internal/nio/ByteArrayBuffer.h | 13 +- .../decaf/internal/nio/CharArrayBuffer.cpp | 288 +++++-- .../main/decaf/internal/nio/CharArrayBuffer.h | 12 +- .../decaf/internal/nio/DoubleArrayBuffer.cpp | 243 ++++-- .../decaf/internal/nio/DoubleArrayBuffer.h | 12 +- .../decaf/internal/nio/FloatArrayBuffer.cpp | 243 ++++-- .../decaf/internal/nio/FloatArrayBuffer.h | 12 +- .../decaf/internal/nio/IntArrayBuffer.cpp | 239 ++++-- .../main/decaf/internal/nio/IntArrayBuffer.h | 12 +- .../decaf/internal/nio/LongArrayBuffer.cpp | 239 ++++-- .../main/decaf/internal/nio/LongArrayBuffer.h | 12 +- .../decaf/internal/nio/ShortArrayBuffer.cpp | 243 ++++-- .../decaf/internal/nio/ShortArrayBuffer.h | 12 +- .../internal/security/SecurityRuntime.cpp | 7 +- .../decaf/internal/security/SecurityRuntime.h | 2 +- .../security/unix/SecureRandomImpl.cpp | 34 +- .../security/windows/SecureRandomImpl.cpp | 38 +- .../decaf/internal/util/ByteArrayAdapter.cpp | 746 +++++++++++++----- .../decaf/internal/util/ByteArrayAdapter.h | 105 ++- .../decaf/internal/util/HexStringParser.cpp | 6 +- .../main/decaf/internal/util/StringUtils.cpp | 17 +- .../main/decaf/internal/util/StringUtils.h | 2 +- .../util/concurrent/PlatformThread.cpp | 14 +- .../util/concurrent/ThreadLocalImpl.cpp | 11 +- .../internal/util/concurrent/Threading.cpp | 145 ++-- .../internal/util/concurrent/Threading.h | 21 +- .../internal/util/concurrent/TransferQueue.h | 2 +- .../internal/util/concurrent/TransferStack.h | 2 +- .../internal/util/concurrent/Transferer.h | 6 +- .../decaf/io/BlockingByteArrayInputStream.cpp | 28 +- .../src/main/decaf/io/BufferedInputStream.cpp | 39 +- .../src/main/decaf/io/BufferedInputStream.h | 4 +- .../main/decaf/io/BufferedOutputStream.cpp | 51 +- .../src/main/decaf/io/BufferedOutputStream.h | 4 +- .../main/decaf/io/ByteArrayInputStream.cpp | 59 +- .../src/main/decaf/io/ByteArrayInputStream.h | 8 +- .../main/decaf/io/ByteArrayOutputStream.cpp | 47 +- .../src/main/decaf/io/ByteArrayOutputStream.h | 4 +- activemq-cpp/src/main/decaf/io/DataInput.h | 12 +- .../src/main/decaf/io/DataInputStream.cpp | 43 +- .../src/main/decaf/io/DataInputStream.h | 12 +- activemq-cpp/src/main/decaf/io/DataOutput.h | 2 - .../src/main/decaf/io/DataOutputStream.cpp | 28 +- .../src/main/decaf/io/EOFException.cpp | 83 -- activemq-cpp/src/main/decaf/io/EOFException.h | 57 ++ .../src/main/decaf/io/FilterInputStream.cpp | 7 +- .../src/main/decaf/io/FilterInputStream.h | 2 - .../src/main/decaf/io/FilterOutputStream.cpp | 35 +- .../src/main/decaf/io/FilterOutputStream.h | 2 - .../src/main/decaf/io/IOException.cpp | 84 -- activemq-cpp/src/main/decaf/io/IOException.h | 57 ++ .../src/main/decaf/io/InputStream.cpp | 24 +- activemq-cpp/src/main/decaf/io/InputStream.h | 12 +- .../src/main/decaf/io/InputStreamReader.cpp | 14 +- .../src/main/decaf/io/InputStreamReader.h | 2 +- .../main/decaf/io/InterruptedIOException.cpp | 83 -- .../main/decaf/io/InterruptedIOException.h | 61 ++ .../src/main/decaf/io/OutputStream.cpp | 38 +- activemq-cpp/src/main/decaf/io/OutputStream.h | 11 +- .../src/main/decaf/io/OutputStreamWriter.cpp | 20 +- .../src/main/decaf/io/OutputStreamWriter.h | 2 +- .../src/main/decaf/io/PushbackInputStream.cpp | 75 +- .../src/main/decaf/io/PushbackInputStream.h | 11 +- activemq-cpp/src/main/decaf/io/Reader.cpp | 15 +- activemq-cpp/src/main/decaf/io/Reader.h | 9 +- .../main/decaf/io/UTFDataFormatException.cpp | 83 -- .../main/decaf/io/UTFDataFormatException.h | 61 ++ .../decaf/io/UnsupportedEncodingException.cpp | 86 -- .../decaf/io/UnsupportedEncodingException.h | 62 ++ activemq-cpp/src/main/decaf/io/Writer.cpp | 16 +- activemq-cpp/src/main/decaf/io/Writer.h | 10 +- .../main/decaf/lang/AbstractStringBuilder.cpp | 228 +++--- .../main/decaf/lang/AbstractStringBuilder.h | 41 +- activemq-cpp/src/main/decaf/lang/Appendable.h | 2 +- .../src/main/decaf/lang/ArrayPointer.h | 51 +- activemq-cpp/src/main/decaf/lang/Byte.cpp | 12 +- activemq-cpp/src/main/decaf/lang/Byte.h | 15 +- .../src/main/decaf/lang/CharSequence.h | 6 +- activemq-cpp/src/main/decaf/lang/Double.cpp | 10 +- activemq-cpp/src/main/decaf/lang/Double.h | 9 +- activemq-cpp/src/main/decaf/lang/Float.cpp | 10 +- activemq-cpp/src/main/decaf/lang/Float.h | 5 +- activemq-cpp/src/main/decaf/lang/Integer.cpp | 58 +- activemq-cpp/src/main/decaf/lang/Integer.h | 17 +- activemq-cpp/src/main/decaf/lang/Long.cpp | 54 +- activemq-cpp/src/main/decaf/lang/Long.h | 15 +- activemq-cpp/src/main/decaf/lang/Pointer.h | 41 +- activemq-cpp/src/main/decaf/lang/Readable.h | 3 +- activemq-cpp/src/main/decaf/lang/Short.cpp | 11 +- activemq-cpp/src/main/decaf/lang/Short.h | 15 +- activemq-cpp/src/main/decaf/lang/String.cpp | 216 ++--- activemq-cpp/src/main/decaf/lang/String.h | 33 +- .../src/main/decaf/lang/StringBuffer.cpp | 5 +- .../src/main/decaf/lang/StringBuffer.h | 51 +- .../src/main/decaf/lang/StringBuilder.cpp | 5 +- .../src/main/decaf/lang/StringBuilder.h | 51 +- activemq-cpp/src/main/decaf/lang/System.cpp | 184 +++-- activemq-cpp/src/main/decaf/lang/System.h | 43 +- activemq-cpp/src/main/decaf/lang/Thread.cpp | 63 +- activemq-cpp/src/main/decaf/lang/Thread.h | 35 +- .../src/main/decaf/lang/Throwable.cpp | 32 - activemq-cpp/src/main/decaf/lang/Throwable.h | 9 + .../ArrayIndexOutOfBoundsException.cpp | 109 --- .../ArrayIndexOutOfBoundsException.h | 155 ---- .../lang/exceptions/ClassCastException.cpp | 84 -- .../lang/exceptions/ClassCastException.h | 119 --- .../exceptions/CloneNotSupportedException.cpp | 87 -- .../exceptions/CloneNotSupportedException.h | 128 --- .../decaf/lang/exceptions/ExceptionDefines.h | 29 +- .../exceptions/IllegalArgumentException.cpp | 85 -- .../exceptions/IllegalArgumentException.h | 118 --- .../IllegalMonitorStateException.cpp | 87 -- .../exceptions/IllegalMonitorStateException.h | 116 --- .../lang/exceptions/IllegalStateException.cpp | 84 -- .../lang/exceptions/IllegalStateException.h | 119 --- .../IllegalThreadStateException.cpp | 87 -- .../exceptions/IllegalThreadStateException.h | 119 --- .../exceptions/IndexOutOfBoundsException.cpp | 85 -- .../exceptions/IndexOutOfBoundsException.h | 115 --- .../lang/exceptions/InterruptedException.cpp | 84 -- .../lang/exceptions/InterruptedException.h | 118 --- .../lang/exceptions/InvalidStateException.cpp | 84 -- .../lang/exceptions/InvalidStateException.h | 128 --- .../exceptions/NegativeArraySizeException.cpp | 87 -- .../exceptions/NegativeArraySizeException.h | 118 --- .../lang/exceptions/NullPointerException.cpp | 84 -- .../lang/exceptions/NullPointerException.h | 119 --- .../lang/exceptions/NumberFormatException.cpp | 84 -- .../lang/exceptions/NumberFormatException.h | 120 --- .../lang/exceptions/OutOfMemoryError.cpp | 84 -- .../decaf/lang/exceptions/OutOfMemoryError.h | 116 --- .../lang/exceptions/RuntimeException.cpp | 84 -- .../decaf/lang/exceptions/RuntimeException.h | 117 --- .../lang/exceptions/SecurityException.cpp | 84 -- .../decaf/lang/exceptions/SecurityException.h | 128 --- .../StringIndexOutOfBoundsException.cpp | 109 --- .../StringIndexOutOfBoundsException.h | 155 ---- .../UnsupportedOperationException.cpp | 88 --- .../UnsupportedOperationException.h | 113 --- .../src/main/decaf/net/DatagramPacket.cpp | 67 +- .../src/main/decaf/net/DatagramPacket.h | 41 +- .../src/main/decaf/net/HttpURLConnection.cpp | 34 +- .../src/main/decaf/net/HttpURLConnection.h | 7 +- .../src/main/decaf/net/InetAddress.cpp | 28 +- .../src/main/decaf/net/ServerSocket.cpp | 52 +- .../src/main/decaf/net/ServerSocket.h | 19 +- activemq-cpp/src/main/decaf/net/Socket.cpp | 109 ++- activemq-cpp/src/main/decaf/net/Socket.h | 29 +- activemq-cpp/src/main/decaf/net/URI.cpp | 11 +- activemq-cpp/src/main/decaf/net/URI.h | 10 +- activemq-cpp/src/main/decaf/net/URL.cpp | 24 +- activemq-cpp/src/main/decaf/net/URL.h | 5 +- .../src/main/decaf/net/URLConnection.cpp | 74 +- .../src/main/decaf/net/URLConnection.h | 11 +- .../src/main/decaf/net/URLDecoder.cpp | 25 +- .../src/main/decaf/net/URLStreamHandler.cpp | 49 +- .../src/main/decaf/net/URLStreamHandler.h | 5 +- .../src/main/decaf/net/ssl/SSLContext.cpp | 166 +++- .../src/main/decaf/net/ssl/SSLContext.h | 11 +- .../src/main/decaf/net/ssl/SSLContextSpi.cpp | 64 +- .../src/main/decaf/net/ssl/SSLContextSpi.h | 11 +- .../main/decaf/net/ssl/SSLServerSocket.cpp | 2 - .../src/main/decaf/net/ssl/SSLServerSocket.h | 11 +- .../src/main/decaf/net/ssl/SSLSocket.cpp | 19 +- .../src/main/decaf/net/ssl/SSLSocket.h | 19 +- activemq-cpp/src/main/decaf/nio/Buffer.cpp | 17 +- activemq-cpp/src/main/decaf/nio/Buffer.h | 8 +- .../main/decaf/nio/BufferUnderflowException.h | 106 --- .../src/main/decaf/nio/ByteBuffer.cpp | 124 ++- activemq-cpp/src/main/decaf/nio/ByteBuffer.h | 55 +- .../src/main/decaf/nio/CharBuffer.cpp | 256 ++++-- activemq-cpp/src/main/decaf/nio/CharBuffer.h | 47 +- .../src/main/decaf/nio/DoubleBuffer.cpp | 129 ++- .../src/main/decaf/nio/DoubleBuffer.h | 29 +- .../src/main/decaf/nio/FloatBuffer.cpp | 118 ++- activemq-cpp/src/main/decaf/nio/FloatBuffer.h | 27 +- activemq-cpp/src/main/decaf/nio/IntBuffer.cpp | 118 ++- activemq-cpp/src/main/decaf/nio/IntBuffer.h | 27 +- .../main/decaf/nio/InvalidMarkException.cpp | 57 +- .../src/main/decaf/nio/InvalidMarkException.h | 86 +- .../src/main/decaf/nio/LongBuffer.cpp | 118 ++- activemq-cpp/src/main/decaf/nio/LongBuffer.h | 23 +- .../decaf/nio/ReadOnlyBufferException.cpp | 56 +- .../main/decaf/nio/ReadOnlyBufferException.h | 79 +- .../src/main/decaf/nio/ShortBuffer.cpp | 117 ++- activemq-cpp/src/main/decaf/nio/ShortBuffer.h | 27 +- .../src/main/decaf/security/MessageDigest.cpp | 7 +- .../src/main/decaf/security/MessageDigest.h | 9 +- .../main/decaf/security/MessageDigestSpi.cpp | 9 +- .../main/decaf/security/MessageDigestSpi.h | 12 +- .../main/decaf/security/ProviderException.cpp | 85 -- .../main/decaf/security/ProviderException.h | 123 --- .../src/main/decaf/security/SecureRandom.cpp | 48 +- .../src/main/decaf/security/SecureRandom.h | 9 +- .../src/main/decaf/util/AbstractCollection.h | 18 +- .../src/main/decaf/util/AbstractList.h | 88 +-- .../src/main/decaf/util/AbstractMap.h | 3 - .../src/main/decaf/util/AbstractQueue.h | 26 +- .../main/decaf/util/AbstractSequentialList.h | 72 +- .../src/main/decaf/util/AbstractSet.h | 6 +- activemq-cpp/src/main/decaf/util/ArrayList.h | 48 +- activemq-cpp/src/main/decaf/util/Arrays.h | 54 +- activemq-cpp/src/main/decaf/util/BitSet.cpp | 111 +-- activemq-cpp/src/main/decaf/util/BitSet.h | 26 +- activemq-cpp/src/main/decaf/util/Collection.h | 32 +- .../src/main/decaf/util/Collections.h | 3 +- .../util/ConcurrentModificationException.cpp | 90 --- .../util/ConcurrentModificationException.h | 108 --- activemq-cpp/src/main/decaf/util/Date.cpp | 2 - activemq-cpp/src/main/decaf/util/Deque.h | 47 +- activemq-cpp/src/main/decaf/util/HashMap.h | 94 +-- activemq-cpp/src/main/decaf/util/HashSet.h | 12 +- activemq-cpp/src/main/decaf/util/Iterator.h | 12 +- activemq-cpp/src/main/decaf/util/LRUCache.h | 29 +- .../src/main/decaf/util/LinkedHashMap.h | 48 +- .../src/main/decaf/util/LinkedHashSet.h | 7 +- activemq-cpp/src/main/decaf/util/LinkedList.h | 179 +++-- activemq-cpp/src/main/decaf/util/List.h | 37 +- .../src/main/decaf/util/ListIterator.h | 14 +- activemq-cpp/src/main/decaf/util/Map.h | 33 +- .../decaf/util/NoSuchElementException.cpp | 84 -- .../main/decaf/util/NoSuchElementException.h | 118 --- .../src/main/decaf/util/PriorityQueue.h | 61 +- .../src/main/decaf/util/Properties.cpp | 48 +- activemq-cpp/src/main/decaf/util/Properties.h | 15 +- activemq-cpp/src/main/decaf/util/Queue.h | 15 +- activemq-cpp/src/main/decaf/util/Random.cpp | 26 +- activemq-cpp/src/main/decaf/util/Random.h | 4 +- activemq-cpp/src/main/decaf/util/Set.h | 122 +-- activemq-cpp/src/main/decaf/util/StlList.h | 76 +- activemq-cpp/src/main/decaf/util/StlMap.h | 72 +- activemq-cpp/src/main/decaf/util/StlQueue.h | 7 +- activemq-cpp/src/main/decaf/util/StlSet.h | 12 +- .../src/main/decaf/util/StringTokenizer.cpp | 13 +- .../src/main/decaf/util/StringTokenizer.h | 6 +- activemq-cpp/src/main/decaf/util/Timer.cpp | 189 +++-- activemq-cpp/src/main/decaf/util/Timer.h | 78 +- activemq-cpp/src/main/decaf/util/UUID.cpp | 59 +- activemq-cpp/src/main/decaf/util/UUID.h | 16 +- .../concurrent/AbstractExecutorService.cpp | 14 +- .../decaf/util/concurrent/BlockingQueue.h | 34 +- .../decaf/util/concurrent/ConcurrentMap.h | 12 +- .../decaf/util/concurrent/ConcurrentStlMap.h | 92 ++- .../util/concurrent/CopyOnWriteArrayList.h | 166 +++- .../util/concurrent/CopyOnWriteArraySet.h | 3 +- .../decaf/util/concurrent/CountDownLatch.cpp | 346 ++++---- .../decaf/util/concurrent/CountDownLatch.h | 14 +- .../src/main/decaf/util/concurrent/Executor.h | 5 +- .../decaf/util/concurrent/ExecutorService.h | 21 +- .../main/decaf/util/concurrent/Executors.cpp | 75 +- .../main/decaf/util/concurrent/Executors.h | 21 +- .../src/main/decaf/util/concurrent/Future.h | 4 +- .../main/decaf/util/concurrent/FutureTask.h | 11 +- .../util/concurrent/LinkedBlockingQueue.h | 89 ++- .../src/main/decaf/util/concurrent/Mutex.cpp | 59 +- .../main/decaf/util/concurrent/Semaphore.cpp | 29 +- .../main/decaf/util/concurrent/Semaphore.h | 55 +- .../decaf/util/concurrent/Synchronizable.h | 40 +- .../decaf/util/concurrent/SynchronousQueue.h | 86 +- .../util/concurrent/ThreadPoolExecutor.cpp | 226 +++--- .../util/concurrent/ThreadPoolExecutor.h | 37 +- .../main/decaf/util/concurrent/TimeUnit.cpp | 28 +- .../src/main/decaf/util/concurrent/TimeUnit.h | 14 +- .../locks/AbstractQueuedSynchronizer.cpp | 182 +++-- .../locks/AbstractQueuedSynchronizer.h | 49 +- .../decaf/util/concurrent/locks/Condition.h | 51 +- .../main/decaf/util/concurrent/locks/Lock.h | 27 +- .../util/concurrent/locks/ReentrantLock.cpp | 57 +- .../util/concurrent/locks/ReentrantLock.h | 49 +- .../locks/ReentrantReadWriteLock.cpp | 149 ++-- .../concurrent/locks/ReentrantReadWriteLock.h | 21 +- .../src/main/decaf/util/logging/Handler.cpp | 7 +- .../src/main/decaf/util/logging/Handler.h | 1 - .../src/main/decaf/util/logging/Level.cpp | 16 +- .../src/main/decaf/util/logging/Level.h | 4 +- .../main/decaf/util/logging/LogManager.cpp | 11 +- .../src/main/decaf/util/logging/LogManager.h | 9 +- .../src/main/decaf/util/logging/Logger.cpp | 11 +- .../src/main/decaf/util/logging/Logger.h | 5 +- .../main/decaf/util/logging/StreamHandler.cpp | 25 +- .../main/decaf/util/logging/StreamHandler.h | 4 +- .../src/main/decaf/util/zip/Adler32.cpp | 34 +- .../src/main/decaf/util/zip/Adler32.h | 2 +- .../src/main/decaf/util/zip/CRC32.cpp | 16 +- activemq-cpp/src/main/decaf/util/zip/CRC32.h | 5 +- .../decaf/util/zip/CheckedInputStream.cpp | 46 +- .../main/decaf/util/zip/CheckedInputStream.h | 3 +- .../decaf/util/zip/CheckedOutputStream.cpp | 46 +- .../main/decaf/util/zip/CheckedOutputStream.h | 3 +- .../src/main/decaf/util/zip/Checksum.h | 8 +- .../src/main/decaf/util/zip/Deflater.cpp | 242 +++--- .../src/main/decaf/util/zip/Deflater.h | 76 +- .../decaf/util/zip/DeflaterOutputStream.cpp | 59 +- .../decaf/util/zip/DeflaterOutputStream.h | 9 +- .../src/main/decaf/util/zip/Inflater.cpp | 204 +++-- .../src/main/decaf/util/zip/Inflater.h | 72 +- .../decaf/util/zip/InflaterInputStream.cpp | 59 +- .../main/decaf/util/zip/InflaterInputStream.h | 9 +- .../activemq/test/AdvisoryTest.cpp | 2 - .../OpenWireMessageListenerRedeliveryTest.cpp | 5 +- .../test/openwire/OpenwireAdvisoryTest.cpp | 18 +- .../OpenwireEnhancedConnectionTest.cpp | 1 - .../openwire_ssl/OpenwireSslAdvisoryTest.cpp | 18 +- .../OpenwireSslEnhancedConnectionTest.cpp | 1 - ...enwireSslMessageListenerRedeliveryTest.cpp | 5 +- .../activemq/test/stomp/StompAdvisoryTest.cpp | 2 - .../activemq/util/CMSProvider.cpp | 59 +- .../core/LazyPropertyUnmarshalTest.cpp | 4 +- .../exceptions/ActiveMQExceptionTest.cpp | 22 +- .../test/activemq/mock/MockBrokerService.cpp | 23 +- .../state/ConnectionStateTrackerTest.cpp | 20 +- .../threads/DedicatedTaskRunnerTest.cpp | 7 +- .../test/activemq/threads/SchedulerTest.cpp | 15 +- .../transport/CorruptedMessageTest.cpp | 93 ++- .../activemq/transport/IOTransportTest.cpp | 31 +- .../transport/TransportRegistryTest.cpp | 13 +- .../correlator/ResponseCorrelatorTest.cpp | 20 +- .../AbstractDiscoveryAgentFactoryTest.cpp | 5 +- .../discovery/AbstractDiscoveryAgentTest.cpp | 5 +- .../discovery/DiscoveryAgentRegistryTest.cpp | 1 - .../DiscoveryTransportFactoryTest.cpp | 1 - .../failover/FailoverTransportTest.cpp | 239 ++++-- .../inactivity/InactivityMonitorTest.cpp | 1 - .../mock/MockTransportFactoryTest.cpp | 1 - .../transport/tcp/SslTransportTest.cpp | 11 +- .../transport/tcp/TcpTransportTest.cpp | 52 +- .../ActiveMQMessageTransformationTest.cpp | 15 +- .../activemq/util/AdvisorySupportTest.cpp | 261 +++--- .../activemq/util/MarshallingSupportTest.cpp | 10 +- .../test/activemq/util/PrimitiveListTest.cpp | 59 +- .../test/activemq/util/PrimitiveMapTest.cpp | 32 +- .../util/PrimitiveValueConverterTest.cpp | 42 +- .../activemq/util/PrimitiveValueNodeTest.cpp | 4 +- .../src/test/activemq/util/URISupportTest.cpp | 17 +- .../wireformat/WireFormatRegistryTest.cpp | 16 +- .../marshal/PrimitiveTypesMarshallerTest.cpp | 1 - .../internal/nio/ByteArrayBufferTest.cpp | 99 ++- .../internal/nio/CharArrayBufferTest.cpp | 135 ++-- .../internal/nio/DoubleArrayBufferTest.cpp | 88 +-- .../internal/nio/FloatArrayBufferTest.cpp | 92 ++- .../decaf/internal/nio/IntArrayBufferTest.cpp | 92 ++- .../internal/nio/LongArrayBufferTest.cpp | 92 ++- .../internal/nio/ShortArrayBufferTest.cpp | 92 ++- .../internal/util/ByteArrayAdapterTest.cpp | 72 +- .../test/decaf/io/BufferedInputStreamTest.cpp | 33 +- .../decaf/io/BufferedOutputStreamTest.cpp | 29 +- .../decaf/io/ByteArrayOutputStreamTest.cpp | 13 +- .../src/test/decaf/io/DataInputStreamTest.cpp | 79 +- .../test/decaf/io/DataOutputStreamTest.cpp | 13 +- .../test/decaf/io/FilterInputStreamTest.cpp | 33 +- .../test/decaf/io/FilterOutputStreamTest.cpp | 31 +- .../test/decaf/io/InputStreamReaderTest.cpp | 7 +- .../src/test/decaf/io/InputStreamTest.cpp | 6 +- .../src/test/decaf/io/OutputStreamTest.cpp | 1 - .../test/decaf/io/OutputStreamWriterTest.cpp | 21 +- .../test/decaf/io/PushbackInputStreamTest.cpp | 14 +- activemq-cpp/src/test/decaf/io/ReaderTest.cpp | 7 +- activemq-cpp/src/test/decaf/io/WriterTest.cpp | 10 +- .../src/test/decaf/lang/ArrayPointerTest.cpp | 18 +- .../src/test/decaf/lang/PointerTest.cpp | 32 +- .../src/test/decaf/lang/StringBufferTest.cpp | 316 ++++---- .../src/test/decaf/lang/StringBuilderTest.cpp | 316 ++++---- .../src/test/decaf/lang/StringTest.cpp | 137 ++-- .../src/test/decaf/lang/ThreadLocalTest.cpp | 9 +- .../src/test/decaf/lang/ThreadTest.cpp | 41 +- .../src/test/decaf/net/ServerSocketTest.cpp | 14 +- .../src/test/decaf/net/SocketTest.cpp | 10 +- activemq-cpp/src/test/decaf/net/URITest.cpp | 6 +- activemq-cpp/src/test/decaf/net/URLTest.cpp | 43 +- .../src/test/decaf/nio/BufferTest.cpp | 7 +- .../test/decaf/security/MessageDigestTest.cpp | 3 - .../test/decaf/security/SecureRandomTest.cpp | 19 +- .../src/test/decaf/util/AbstractListTest.cpp | 64 +- .../decaf/util/AbstractSequentialListTest.cpp | 72 +- .../src/test/decaf/util/ArrayListTest.cpp | 62 +- .../src/test/decaf/util/ArraysTest.cpp | 28 +- .../src/test/decaf/util/BitSetTest.cpp | 59 +- .../src/test/decaf/util/HashCodeTest.cpp | 1 - .../src/test/decaf/util/HashMapTest.cpp | 37 +- .../src/test/decaf/util/HashSetTest.cpp | 7 +- .../src/test/decaf/util/LRUCacheTest.cpp | 6 +- .../src/test/decaf/util/LinkedHashMapTest.cpp | 37 +- .../src/test/decaf/util/LinkedHashSetTest.cpp | 7 +- .../src/test/decaf/util/LinkedListTest.cpp | 94 +-- activemq-cpp/src/test/decaf/util/ListTest.cpp | 52 +- .../src/test/decaf/util/PriorityQueueTest.cpp | 30 +- .../src/test/decaf/util/PropertiesTest.cpp | 12 +- .../src/test/decaf/util/StlMapTest.cpp | 40 +- .../test/decaf/util/StringTokenizerTest.cpp | 2 +- .../src/test/decaf/util/TimerTest.cpp | 364 ++++----- activemq-cpp/src/test/decaf/util/UUIDTest.cpp | 63 +- .../AbstractExecutorServiceTest.cpp | 33 +- .../util/concurrent/ConcurrentStlMapTest.cpp | 38 +- .../concurrent/CopyOnWriteArrayListTest.cpp | 64 +- .../concurrent/CopyOnWriteArraySetTest.cpp | 4 +- .../util/concurrent/CountDownLatchTest.cpp | 71 +- .../decaf/util/concurrent/ExecutorsTest.cpp | 30 +- .../util/concurrent/ExecutorsTestSupport.cpp | 11 +- .../util/concurrent/ExecutorsTestSupport.h | 12 +- .../decaf/util/concurrent/FutureTaskTest.cpp | 45 +- .../concurrent/LinkedBlockingQueueTest.cpp | 67 +- .../test/decaf/util/concurrent/MutexTest.cpp | 9 +- .../decaf/util/concurrent/SemaphoreTest.cpp | 210 +++-- .../concurrent/ThreadPoolExecutorTest.cpp | 113 +-- .../decaf/util/concurrent/TimeUnitTest.cpp | 4 +- .../locks/AbstractQueuedSynchronizerTest.cpp | 145 ++-- .../concurrent/locks/ReentrantLockTest.cpp | 65 +- .../locks/ReentrantReadWriteLockTest.cpp | 63 +- .../src/test/decaf/util/zip/Adler32Test.cpp | 11 +- .../src/test/decaf/util/zip/CRC32Test.cpp | 11 +- .../decaf/util/zip/CheckedInputStreamTest.cpp | 1 - .../util/zip/CheckedOutputStreamTest.cpp | 5 +- .../util/zip/DeflaterOutputStreamTest.cpp | 21 +- .../src/test/decaf/util/zip/DeflaterTest.cpp | 42 +- .../util/zip/InflaterInputStreamTest.cpp | 16 +- .../src/test/decaf/util/zip/InflaterTest.cpp | 14 +- 762 files changed, 16289 insertions(+), 17001 deletions(-) rename activemq-cpp/src/main/{decaf/nio => activemq/exceptions}/BufferUnderflowException.cpp (55%) create mode 100644 activemq-cpp/src/main/activemq/exceptions/BufferUnderflowException.h create mode 100644 activemq-cpp/src/main/activemq/exceptions/ExceptionTypes.h create mode 100644 activemq-cpp/src/main/activemq/exceptions/IoCatchMacros.h create mode 100644 activemq-cpp/src/main/activemq/exceptions/IoExceptions.cpp create mode 100644 activemq-cpp/src/main/activemq/exceptions/IoExceptions.h create mode 100644 activemq-cpp/src/main/activemq/exceptions/StdExceptionCatchMacros.h mode change 100755 => 100644 activemq-cpp/src/main/activemq/transport/mock/MockTransport.cpp delete mode 100644 activemq-cpp/src/main/decaf/io/EOFException.cpp delete mode 100644 activemq-cpp/src/main/decaf/io/IOException.cpp delete mode 100644 activemq-cpp/src/main/decaf/io/InterruptedIOException.cpp delete mode 100644 activemq-cpp/src/main/decaf/io/UTFDataFormatException.cpp delete mode 100644 activemq-cpp/src/main/decaf/io/UnsupportedEncodingException.cpp mode change 100755 => 100644 activemq-cpp/src/main/decaf/lang/ArrayPointer.h delete mode 100644 activemq-cpp/src/main/decaf/lang/Throwable.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/ArrayIndexOutOfBoundsException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/ArrayIndexOutOfBoundsException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/ClassCastException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/ClassCastException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/CloneNotSupportedException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/CloneNotSupportedException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/IllegalArgumentException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/IllegalArgumentException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/IllegalMonitorStateException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/IllegalMonitorStateException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/IllegalStateException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/IllegalStateException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/IllegalThreadStateException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/IllegalThreadStateException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/IndexOutOfBoundsException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/IndexOutOfBoundsException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/InterruptedException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/InterruptedException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/InvalidStateException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/InvalidStateException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/NegativeArraySizeException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/NegativeArraySizeException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/NullPointerException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/NullPointerException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/NumberFormatException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/NumberFormatException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/OutOfMemoryError.cpp delete mode 100755 activemq-cpp/src/main/decaf/lang/exceptions/OutOfMemoryError.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/RuntimeException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/RuntimeException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/SecurityException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/SecurityException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/StringIndexOutOfBoundsException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/StringIndexOutOfBoundsException.h delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/UnsupportedOperationException.cpp delete mode 100644 activemq-cpp/src/main/decaf/lang/exceptions/UnsupportedOperationException.h delete mode 100644 activemq-cpp/src/main/decaf/nio/BufferUnderflowException.h delete mode 100644 activemq-cpp/src/main/decaf/security/ProviderException.cpp delete mode 100644 activemq-cpp/src/main/decaf/security/ProviderException.h delete mode 100644 activemq-cpp/src/main/decaf/util/ConcurrentModificationException.cpp delete mode 100755 activemq-cpp/src/main/decaf/util/ConcurrentModificationException.h delete mode 100644 activemq-cpp/src/main/decaf/util/NoSuchElementException.cpp delete mode 100644 activemq-cpp/src/main/decaf/util/NoSuchElementException.h mode change 100755 => 100644 activemq-cpp/src/test/decaf/lang/ArrayPointerTest.cpp diff --git a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/CommandSourceGenerator.java b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/CommandSourceGenerator.java index 2aec094b2..07a7fb95d 100644 --- a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/CommandSourceGenerator.java +++ b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/CommandSourceGenerator.java @@ -42,7 +42,6 @@ public void generate( PrintWriter out ) { out.println("using namespace activemq::exceptions;"); out.println("using namespace activemq::commands;"); out.println("using namespace decaf::lang;"); - out.println("using namespace decaf::lang::exceptions;"); if( isComparable() ) { out.println("using namespace decaf::internal::util;"); } @@ -95,7 +94,7 @@ public void generate( PrintWriter out ) { out.println(" const "+getClassName()+"* srcPtr = dynamic_cast(src);"); out.println(""); out.println(" if (srcPtr == NULL || src == NULL) {"); - out.println(" throw decaf::lang::exceptions::NullPointerException("); + out.println(" throw NullPointerException("); out.println(" __FILE__, __LINE__,"); out.println(" \""+getClassName()+"::copyDataStructure - src is NULL or invalid\");"); out.println(" }"); @@ -203,7 +202,7 @@ protected void populateIncludeFilesSet() { includes.add(""); includes.add(""); includes.add(""); - includes.add(""); + includes.add(""); if( isHashable() ) { includes.add(""); } diff --git a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/MessageSourceGenerator.java b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/MessageSourceGenerator.java index 282deb473..5a1e971d1 100644 --- a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/MessageSourceGenerator.java +++ b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/MessageSourceGenerator.java @@ -118,9 +118,9 @@ protected void generateAdditionalMethods( PrintWriter out ) { out.println(" &properties, marshalledProperties );"); out.println(" }"); out.println(" }"); - out.println(" AMQ_CATCH_RETHROW(decaf::io::IOException)"); - out.println(" AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, decaf::io::IOException)"); - out.println(" AMQ_CATCHALL_THROW(decaf::io::IOException)"); + out.println(" AMQ_IOSTREAM_CATCH_RETHROW()"); + out.println(" AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION()"); + out.println(" AMQ_IOSTREAM_CATCHALL_THROW()"); out.println("}"); out.println(""); out.println("////////////////////////////////////////////////////////////////////////////////"); @@ -130,9 +130,9 @@ protected void generateAdditionalMethods( PrintWriter out ) { out.println(" wireformat::openwire::marshal::PrimitiveTypesMarshaller::unmarshal("); out.println(" &properties, marshalledProperties);"); out.println(" }"); - out.println(" AMQ_CATCH_RETHROW(decaf::io::IOException)"); - out.println(" AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, decaf::io::IOException)"); - out.println(" AMQ_CATCHALL_THROW(decaf::io::IOException)"); + out.println(" AMQ_IOSTREAM_CATCH_RETHROW()"); + out.println(" AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION()"); + out.println(" AMQ_IOSTREAM_CATCHALL_THROW()"); out.println("}"); out.println(""); } diff --git a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingClassesGenerator.java b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingClassesGenerator.java index ddf8d891a..87d100058 100644 --- a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingClassesGenerator.java +++ b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingClassesGenerator.java @@ -645,9 +645,9 @@ protected void generateFile(PrintWriter out) throws Exception { } out.println(" }"); -out.println(" AMQ_CATCH_RETHROW(decaf::io::IOException)" ); -out.println(" AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, decaf::io::IOException)" ); -out.println(" AMQ_CATCHALL_THROW(decaf::io::IOException)" ); +out.println(" AMQ_IOSTREAM_CATCH_RETHROW()" ); +out.println(" AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION()" ); +out.println(" AMQ_IOSTREAM_CATCHALL_THROW()" ); out.println("}"); out.println(""); out.println("///////////////////////////////////////////////////////////////////////////////"); @@ -680,9 +680,9 @@ protected void generateFile(PrintWriter out) throws Exception { out.println(""); out.println(" return rc + "+baseSize+";"); out.println(" }"); -out.println(" AMQ_CATCH_RETHROW(decaf::io::IOException)" ); -out.println(" AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, decaf::io::IOException)" ); -out.println(" AMQ_CATCHALL_THROW(decaf::io::IOException)" ); +out.println(" AMQ_IOSTREAM_CATCH_RETHROW()" ); +out.println(" AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION()" ); +out.println(" AMQ_IOSTREAM_CATCHALL_THROW()" ); out.println("}"); out.println(""); out.println("///////////////////////////////////////////////////////////////////////////////"); @@ -712,9 +712,9 @@ protected void generateFile(PrintWriter out) throws Exception { } out.println(" }"); -out.println(" AMQ_CATCH_RETHROW(decaf::io::IOException)" ); -out.println(" AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException, decaf::io::IOException)" ); -out.println(" AMQ_CATCHALL_THROW(decaf::io::IOException)" ); +out.println(" AMQ_IOSTREAM_CATCH_RETHROW()" ); +out.println(" AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION()" ); +out.println(" AMQ_IOSTREAM_CATCHALL_THROW()" ); out.println("}"); out.println(""); out.println("///////////////////////////////////////////////////////////////////////////////"); @@ -747,9 +747,9 @@ protected void generateFile(PrintWriter out) throws Exception { } out.println(" }"); -out.println(" AMQ_CATCH_RETHROW(decaf::io::IOException)" ); -out.println(" AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, decaf::io::IOException)" ); -out.println(" AMQ_CATCHALL_THROW(decaf::io::IOException)" ); +out.println(" AMQ_IOSTREAM_CATCH_RETHROW()" ); +out.println(" AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION()" ); +out.println(" AMQ_IOSTREAM_CATCHALL_THROW()" ); out.println("}"); out.println(""); out.println("///////////////////////////////////////////////////////////////////////////////"); @@ -783,9 +783,9 @@ protected void generateFile(PrintWriter out) throws Exception { } out.println(" }"); -out.println(" AMQ_CATCH_RETHROW(decaf::io::IOException)" ); -out.println(" AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, decaf::io::IOException)" ); -out.println(" AMQ_CATCHALL_THROW(decaf::io::IOException)" ); +out.println(" AMQ_IOSTREAM_CATCH_RETHROW()" ); +out.println(" AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION()" ); +out.println(" AMQ_IOSTREAM_CATCHALL_THROW()" ); out.println("}"); out.println(""); } diff --git a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingHeadersGenerator.java b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingHeadersGenerator.java index b071d4ab7..f9a9c81fb 100644 --- a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingHeadersGenerator.java +++ b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingHeadersGenerator.java @@ -238,7 +238,7 @@ protected void generateFile(PrintWriter out) throws Exception { out.println(""); out.println("#include "); out.println("#include "); -out.println("#include "); +out.println("#include "); out.println("#include "); out.println("#include "); out.println("#include "); diff --git a/activemq-cpp/src/examples/advisories/AdvisoryConsumer.cpp b/activemq-cpp/src/examples/advisories/AdvisoryConsumer.cpp index 01ecd1745..9e26b3ea3 100644 --- a/activemq-cpp/src/examples/advisories/AdvisoryConsumer.cpp +++ b/activemq-cpp/src/examples/advisories/AdvisoryConsumer.cpp @@ -20,20 +20,21 @@ #include #include #include -#include + +#include #include #include +#include +#include using namespace std; using namespace activemq; using namespace activemq::commands; +using namespace activemq::exceptions; using namespace activemqcpp; using namespace activemqcpp::examples; using namespace activemqcpp::examples::advisories; -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// AdvisoryConsumer::AdvisoryConsumer(cms::Session* session) diff --git a/activemq-cpp/src/examples/advisories/AdvisoryProducer.cpp b/activemq-cpp/src/examples/advisories/AdvisoryProducer.cpp index c8ffe8fcd..38e66cf37 100644 --- a/activemq-cpp/src/examples/advisories/AdvisoryProducer.cpp +++ b/activemq-cpp/src/examples/advisories/AdvisoryProducer.cpp @@ -21,15 +21,18 @@ #include #include #include -#include + +#include +#include +#include using namespace std; +using namespace activemq::exceptions; using namespace activemqcpp; using namespace activemqcpp::examples; using namespace activemqcpp::examples::advisories; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// AdvisoryProducer::AdvisoryProducer(cms::Session* session) diff --git a/activemq-cpp/src/examples/advisories/TempDestinationAdvisoryConsumer.cpp b/activemq-cpp/src/examples/advisories/TempDestinationAdvisoryConsumer.cpp index feb72ca4b..7666e16d9 100644 --- a/activemq-cpp/src/examples/advisories/TempDestinationAdvisoryConsumer.cpp +++ b/activemq-cpp/src/examples/advisories/TempDestinationAdvisoryConsumer.cpp @@ -20,12 +20,11 @@ #include #include #include +#include #include #include #include -#include -#include -#include +#include using namespace std; using namespace activemqcpp; @@ -34,9 +33,7 @@ using namespace activemqcpp::examples::advisories; using namespace activemq; using namespace activemq::commands; using namespace activemq::core; -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using namespace activemq::exceptions; //////////////////////////////////////////////////////////////////////////////// TempDestinationAdvisoryConsumer::TempDestinationAdvisoryConsumer( @@ -78,12 +75,18 @@ void TempDestinationAdvisoryConsumer::onMessage(const cms::Message* message) std::cout << "Advisory Message contains a Command Object!" << std::endl; - try - { - std::shared_ptr info = - std::dynamic_pointer_cast( - amqMessage->getDataStructure()); + std::shared_ptr info = + std::dynamic_pointer_cast( + amqMessage->getDataStructure()); + if (!info) + { + std::cout << "ERROR: Expected the Command to be a " + "DestinationInfo, " + << "it wasn't so PANIC!!" << std::endl; + } + else + { unsigned char operationType = info->getOperationType(); if (operationType == @@ -106,12 +109,6 @@ void TempDestinationAdvisoryConsumer::onMessage(const cms::Message* message) << std::endl; } } - catch (ClassCastException& ex) - { - std::cout << "ERROR: Expected the Command to be a " - "DestinationInfo, " - << "it wasn't so PANIC!!" << std::endl; - } } } else diff --git a/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.cpp b/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.cpp index 03c5d321b..5c4e0b7d2 100644 --- a/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.cpp +++ b/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.cpp @@ -17,8 +17,10 @@ #include "ConnectionFactoryMgr.h" #include +#include using namespace std; +using namespace activemq::exceptions; using namespace cms; using namespace decaf; using namespace decaf::lang; @@ -89,7 +91,7 @@ ConnectionFactory* ConnectionFactoryMgr::getConnectionFactory( { connectionFactory = connectionFactories->get(url); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { } diff --git a/activemq-cpp/src/examples/stress-test/BrokerMonitor.cpp b/activemq-cpp/src/examples/stress-test/BrokerMonitor.cpp index 0a5e2286c..3cea833b7 100644 --- a/activemq-cpp/src/examples/stress-test/BrokerMonitor.cpp +++ b/activemq-cpp/src/examples/stress-test/BrokerMonitor.cpp @@ -34,7 +34,6 @@ extern bool VERBOSE; using namespace cms; using namespace cms::stress; using namespace activemq::cmsutil; -using namespace decaf::lang::exceptions; using namespace decaf::lang; using namespace decaf::util; using namespace decaf::util::concurrent; diff --git a/activemq-cpp/src/examples/stress-test/CmsStress.cpp b/activemq-cpp/src/examples/stress-test/CmsStress.cpp index 2db490608..e67942599 100644 --- a/activemq-cpp/src/examples/stress-test/CmsStress.cpp +++ b/activemq-cpp/src/examples/stress-test/CmsStress.cpp @@ -33,7 +33,6 @@ using namespace cms; using namespace cms::stress; using namespace activemq::library; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::atomic; diff --git a/activemq-cpp/src/examples/stress-test/ConnectionFactoryMgr.cpp b/activemq-cpp/src/examples/stress-test/ConnectionFactoryMgr.cpp index ab80c0dfa..e9650e3fe 100644 --- a/activemq-cpp/src/examples/stress-test/ConnectionFactoryMgr.cpp +++ b/activemq-cpp/src/examples/stress-test/ConnectionFactoryMgr.cpp @@ -17,9 +17,10 @@ #include "ConnectionFactoryMgr.h" #include +#include -using namespace decaf::lang::exceptions; using namespace activemq::core; +using namespace activemq::exceptions; using namespace decaf::lang; using namespace cms; using namespace cms::stress; @@ -82,7 +83,7 @@ ConnectionFactory* ConnectionFactoryMgr::getConnectionFactory( connectionFactory = connectionFactories->get(url); } } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { } diff --git a/activemq-cpp/src/main/CMakeLists.txt b/activemq-cpp/src/main/CMakeLists.txt index e6bbbd080..41e64001b 100644 --- a/activemq-cpp/src/main/CMakeLists.txt +++ b/activemq-cpp/src/main/CMakeLists.txt @@ -128,6 +128,8 @@ set(ACTIVEMQ_CPP_SOURCES activemq/exceptions/ActiveMQException.cpp activemq/exceptions/BrokerException.cpp activemq/exceptions/ConnectionFailedException.cpp + activemq/exceptions/BufferUnderflowException.cpp + activemq/exceptions/IoExceptions.cpp activemq/io/LoggingInputStream.cpp activemq/io/LoggingOutputStream.cpp activemq/library/ActiveMQCPP.cpp @@ -402,21 +404,16 @@ set(ACTIVEMQ_CPP_SOURCES decaf/io/DataInputStream.cpp decaf/io/DataOutput.cpp decaf/io/DataOutputStream.cpp - decaf/io/EOFException.cpp decaf/io/FileDescriptor.cpp decaf/io/FilterInputStream.cpp decaf/io/FilterOutputStream.cpp decaf/io/Flushable.cpp - decaf/io/IOException.cpp decaf/io/InputStream.cpp decaf/io/InputStreamReader.cpp - decaf/io/InterruptedIOException.cpp decaf/io/OutputStream.cpp decaf/io/OutputStreamWriter.cpp decaf/io/PushbackInputStream.cpp decaf/io/Reader.cpp - decaf/io/UTFDataFormatException.cpp - decaf/io/UnsupportedEncodingException.cpp decaf/io/Writer.cpp decaf/lang/AbstractStringBuilder.cpp decaf/lang/Appendable.cpp @@ -444,26 +441,7 @@ set(ACTIVEMQ_CPP_SOURCES decaf/lang/Thread.cpp decaf/lang/ThreadGroup.cpp decaf/lang/ThreadLocal.cpp - decaf/lang/Throwable.cpp decaf/lang/Types.cpp - decaf/lang/exceptions/ArrayIndexOutOfBoundsException.cpp - decaf/lang/exceptions/ClassCastException.cpp - decaf/lang/exceptions/CloneNotSupportedException.cpp - decaf/lang/exceptions/IllegalArgumentException.cpp - decaf/lang/exceptions/IllegalMonitorStateException.cpp - decaf/lang/exceptions/IllegalStateException.cpp - decaf/lang/exceptions/IllegalThreadStateException.cpp - decaf/lang/exceptions/IndexOutOfBoundsException.cpp - decaf/lang/exceptions/InterruptedException.cpp - decaf/lang/exceptions/InvalidStateException.cpp - decaf/lang/exceptions/NegativeArraySizeException.cpp - decaf/lang/exceptions/NullPointerException.cpp - decaf/lang/exceptions/NumberFormatException.cpp - decaf/lang/exceptions/OutOfMemoryError.cpp - decaf/lang/exceptions/RuntimeException.cpp - decaf/lang/exceptions/SecurityException.cpp - decaf/lang/exceptions/StringIndexOutOfBoundsException.cpp - decaf/lang/exceptions/UnsupportedOperationException.cpp decaf/net/BindException.cpp decaf/net/ConnectException.cpp decaf/net/ContentHandlerFactory.cpp @@ -503,7 +481,6 @@ set(ACTIVEMQ_CPP_SOURCES decaf/net/UnknownServiceException.cpp decaf/nio/Buffer.cpp decaf/nio/BufferOverflowException.cpp - decaf/nio/BufferUnderflowException.cpp decaf/nio/ByteBuffer.cpp decaf/nio/CharBuffer.cpp decaf/nio/DoubleBuffer.cpp @@ -525,7 +502,6 @@ set(ACTIVEMQ_CPP_SOURCES decaf/security/NoSuchProviderException.cpp decaf/security/Principal.cpp decaf/security/Provider.cpp - decaf/security/ProviderException.cpp decaf/security/ProviderService.cpp decaf/security/PublicKey.cpp decaf/security/SecureRandom.cpp @@ -553,7 +529,6 @@ set(ACTIVEMQ_CPP_SOURCES decaf/util/Collection.cpp decaf/util/Collections.cpp decaf/util/Comparator.cpp - decaf/util/ConcurrentModificationException.cpp decaf/util/Date.cpp decaf/util/Deque.cpp decaf/util/HashCode.cpp @@ -568,7 +543,6 @@ set(ACTIVEMQ_CPP_SOURCES decaf/util/ListIterator.cpp decaf/util/Map.cpp decaf/util/MapEntry.cpp - decaf/util/NoSuchElementException.cpp decaf/util/PriorityQueue.cpp decaf/util/Properties.cpp decaf/util/Queue.cpp diff --git a/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp b/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp index ab145087c..5f82f1eac 100644 --- a/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp +++ b/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp @@ -250,8 +250,7 @@ void CmsTemplate::checkDefaultDestination() { throw IllegalStateException( "No defaultDestination or defaultDestinationName specified." - "Check configuration of CmsTemplate.", - NULL); + "Check configuration of CmsTemplate."); } } diff --git a/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.h b/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.h index 028dcbffe..181e09b80 100644 --- a/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.h +++ b/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.h @@ -716,7 +716,7 @@ namespace cmsutil /** * Checks that the default destination is valid, if not throws * an exception. - * @throws decaf::lang::exceptions::IllegalStateException thrown + * @throws cms::IllegalStateException * if the default destination is invalid. */ void checkDefaultDestination(); diff --git a/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp b/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp index eb8b663e2..bd2ef6acf 100644 --- a/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp +++ b/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp @@ -17,9 +17,11 @@ #include "DynamicDestinationResolver.h" #include "ResourceLifecycleManager.h" +#include #include using namespace activemq::cmsutil; +using namespace activemq::exceptions; using namespace decaf::util; using namespace cms; using namespace std; @@ -34,7 +36,7 @@ cms::Topic* DynamicDestinationResolver::SessionResolver::getTopic( // See if we already have a topic with this name. topic = topicMap.get(topicName); } - catch (decaf::util::NoSuchElementException& ex) + catch (NoSuchElementException&) { // Create a new topic. topic = session->createTopic(topicName); @@ -58,7 +60,7 @@ cms::Queue* DynamicDestinationResolver::SessionResolver::getQueue( // See if we already have a queue with this name. queue = queueMap.get(queueName); } - catch (decaf::util::NoSuchElementException& ex) + catch (NoSuchElementException&) { // Create a new queue. queue = session->createQueue(queueName); @@ -117,7 +119,7 @@ cms::Destination* DynamicDestinationResolver::resolveDestinationName( { resolver = sessionResolverMap.get(session); } - catch (decaf::util::NoSuchElementException& ex) + catch (NoSuchElementException&) { resolver = new SessionResolver(session, resourceLifecycleManager); sessionResolverMap.put(session, resolver); diff --git a/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp b/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp index 505ea7d83..63fd3bc2d 100644 --- a/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp +++ b/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp @@ -18,6 +18,7 @@ #include "PooledSession.h" #include "ResourceLifecycleManager.h" #include "SessionPool.h" +#include #include #include @@ -28,6 +29,7 @@ using namespace cms; using namespace decaf::util; using namespace activemq::cmsutil; +using namespace activemq::exceptions; /** * A catch-all that throws an CMSException. @@ -124,7 +126,7 @@ cms::MessageProducer* PooledSession::createCachedProducer( { cachedProducer = producerCache.get(key); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { // No producer exists for this destination - start by creating // a new producer resource. @@ -171,7 +173,7 @@ cms::MessageConsumer* PooledSession::createCachedConsumer( { cachedConsumer = consumerCache.get(key); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { // No producer exists for this destination - start by creating // a new consumer resource. diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp b/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp index 2e3449726..a80f91912 100644 --- a/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp +++ b/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp @@ -19,10 +19,9 @@ #include #include -#include #include -#include +#include #include #include @@ -32,8 +31,6 @@ using namespace activemq::util; using namespace activemq::commands; using namespace activemq::exceptions; using namespace decaf::io; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -129,12 +126,19 @@ void ActiveMQBytesMessage::copyDataStructure(const DataStructure* src) const ActiveMQBytesMessage* srcPtr = dynamic_cast(src); - if (srcPtr == NULL || src == NULL) + if (src == NULL) { - throw decaf::lang::exceptions::NullPointerException( - __FILE__, - __LINE__, - "ActiveMQBytesMessage::copyDataStructure - src is NULL or invalid"); + throw NullPointerException(__FILE__, + __LINE__, + "ActiveMQBytesMessage::copyDataStructure - " + "src is NULL."); + } + + if (srcPtr == NULL) + { + throw TypeMismatchException( + "ActiveMQBytesMessage::copyDataStructure - src is not an " + "ActiveMQBytesMessage."); } ActiveMQBytesMessage* nonConstSrc = @@ -244,18 +248,7 @@ bool ActiveMQBytesMessage::readBoolean() const { return this->dataIn->readBoolean(); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -266,14 +259,7 @@ void ActiveMQBytesMessage::writeBoolean(bool value) { this->dataOut->writeBoolean(value); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -284,18 +270,7 @@ unsigned char ActiveMQBytesMessage::readByte() const { return (unsigned char)this->dataIn->readByte(); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -306,14 +281,7 @@ void ActiveMQBytesMessage::writeByte(unsigned char value) { this->dataOut->writeByte(value); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -330,14 +298,7 @@ void ActiveMQBytesMessage::writeBytes(const std::vector& value) { this->dataOut->write(&value[0], (int)value.size()); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -375,18 +336,7 @@ int ActiveMQBytesMessage::readBytes(unsigned char* buffer, int length) const return n; } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -399,14 +349,7 @@ void ActiveMQBytesMessage::writeBytes(const unsigned char* value, { this->dataOut->write(value, length, offset, length); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -417,18 +360,7 @@ char ActiveMQBytesMessage::readChar() const { return this->dataIn->readChar(); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -439,14 +371,7 @@ void ActiveMQBytesMessage::writeChar(char value) { this->dataOut->writeChar(value); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -457,18 +382,7 @@ float ActiveMQBytesMessage::readFloat() const { return this->dataIn->readFloat(); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -479,14 +393,7 @@ void ActiveMQBytesMessage::writeFloat(float value) { this->dataOut->writeFloat(value); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -497,18 +404,7 @@ double ActiveMQBytesMessage::readDouble() const { return this->dataIn->readDouble(); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -519,14 +415,7 @@ void ActiveMQBytesMessage::writeDouble(double value) { this->dataOut->writeDouble(value); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -537,18 +426,7 @@ short ActiveMQBytesMessage::readShort() const { return this->dataIn->readShort(); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -559,14 +437,7 @@ void ActiveMQBytesMessage::writeShort(short value) { this->dataOut->writeShort(value); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -577,18 +448,7 @@ unsigned short ActiveMQBytesMessage::readUnsignedShort() const { return this->dataIn->readUnsignedShort(); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -599,14 +459,7 @@ void ActiveMQBytesMessage::writeUnsignedShort(unsigned short value) { this->dataOut->writeUnsignedShort(value); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -617,18 +470,7 @@ int ActiveMQBytesMessage::readInt() const { return this->dataIn->readInt(); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -639,14 +481,7 @@ void ActiveMQBytesMessage::writeInt(int value) { this->dataOut->writeInt(value); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -657,18 +492,7 @@ long long ActiveMQBytesMessage::readLong() const { return this->dataIn->readLong(); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -679,14 +503,7 @@ void ActiveMQBytesMessage::writeLong(long long value) { this->dataOut->writeLong(value); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -697,18 +514,7 @@ std::string ActiveMQBytesMessage::readString() const { return this->dataIn->readString(); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -719,14 +525,7 @@ void ActiveMQBytesMessage::writeString(const std::string& value) { this->dataOut->writeChars(value); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -737,18 +536,7 @@ std::string ActiveMQBytesMessage::readUTF() const { return this->dataIn->readUTF(); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (IOException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -759,14 +547,7 @@ void ActiveMQBytesMessage::writeUTF(const std::string& value) { this->dataOut->writeUTF(value); } - catch (EOFException& ex) - { - throw CMSExceptionSupport::createMessageEOFException(ex); - } - catch (Exception& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() } //////////////////////////////////////////////////////////////////////////////// @@ -831,10 +612,7 @@ void ActiveMQBytesMessage::initializeReading() const DataInputStream dis(is); this->length = dis.readInt(); } - catch (IOException& ex) - { - throw CMSExceptionSupport::create(ex); - } + AMQ_CATCH_DECAF_IOSTREAM_IOEXCEPTION_TO_CMS() is = new InflaterInputStream(is, true); } diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp b/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp index 6544bf5ed..851770654 100644 --- a/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp +++ b/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp @@ -24,11 +24,12 @@ #include #include +#include #include -#include #include #include #include +#include using namespace activemq; using namespace activemq::util; @@ -36,8 +37,6 @@ using namespace activemq::commands; using namespace decaf::internal::util; using namespace decaf::util; -using namespace decaf::lang::exceptions; - //////////////////////////////////////////////////////////////////////////////// const std::string ActiveMQDestination::DEFAULT_ORDERED_TARGET = "coordinator"; const std::string ActiveMQDestination::TEMP_PREFIX = "{TD{"; @@ -138,9 +137,7 @@ void ActiveMQDestination::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "BrokerId::copyDataStructure - src is NULL or invalid"); } @@ -262,11 +259,9 @@ std::shared_ptr ActiveMQDestination::createDestination( result.reset(new ActiveMQTempTopic(name)); return result; default: - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Invalid default destination type: %d", - type); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid default destination type: " + std::to_string(type)); } } @@ -284,10 +279,10 @@ std::string ActiveMQDestination::getDestinationTypeAsString() const case cms::Destination::TEMPORARY_TOPIC: return "TempTopic"; default: - throw new IllegalArgumentException(__FILE__, - __LINE__, - "Invalid destination type: %d", - (int)getDestinationType()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid destination type: " + + std::to_string((int)getDestinationType())); } } diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp b/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp index 3a3652809..2af148ea5 100644 --- a/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp +++ b/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp @@ -18,8 +18,8 @@ #include #include -#include - +#include +#include #include #include #include @@ -27,13 +27,13 @@ #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; using namespace activemq; @@ -155,73 +155,55 @@ void ActiveMQMapMessage::beforeMarshal(WireFormat* wireFormat) clearBody(); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// PrimitiveMap& ActiveMQMapMessage::getMap() { - try - { - this->checkMapIsUnmarshalled(); - return *map; - } - AMQ_CATCH_RETHROW(NullPointerException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - AMQ_CATCHALL_THROW(NullPointerException) + this->checkMapIsUnmarshalled(); + return *map; } //////////////////////////////////////////////////////////////////////////////// const PrimitiveMap& ActiveMQMapMessage::getMap() const { - try - { - this->checkMapIsUnmarshalled(); - return *map; - } - AMQ_CATCH_RETHROW(NullPointerException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - AMQ_CATCHALL_THROW(NullPointerException) + this->checkMapIsUnmarshalled(); + return *map; } //////////////////////////////////////////////////////////////////////////////// void ActiveMQMapMessage::checkMapIsUnmarshalled() const { - try + if (map.get() == NULL && !getContent().empty()) { - if (map.get() == NULL && !getContent().empty()) - { - InputStream* is = new ByteArrayInputStream(getContent()); + InputStream* is = new ByteArrayInputStream(getContent()); - if (isCompressed()) - { - is = new InflaterInputStream(is, true); - is = new BufferedInputStream(is, true); - } + if (isCompressed()) + { + is = new InflaterInputStream(is, true); + is = new BufferedInputStream(is, true); + } - DataInputStream dataIn(is, true); + DataInputStream dataIn(is, true); - map.reset(PrimitiveTypesMarshaller::unmarshalMap(dataIn)); + map.reset(PrimitiveTypesMarshaller::unmarshalMap(dataIn)); - if (map.get() == NULL) - { - throw NullPointerException( - __FILE__, - __LINE__, - "ActiveMQMapMessage::getMap() - All attempts to create a " - "map have failed."); - } - } - else if (map.get() == NULL) + if (map.get() == NULL) { - map.reset(new PrimitiveMap()); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "ActiveMQMapMessage::getMap() - All attempts to create a " + "map have failed."); } } - AMQ_CATCH_RETHROW(NullPointerException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - AMQ_CATCHALL_THROW(NullPointerException) + else if (map.get() == NULL) + { + map.reset(new PrimitiveMap()); + } } //////////////////////////////////////////////////////////////////////////////// @@ -304,10 +286,7 @@ bool ActiveMQMapMessage::getBoolean(const std::string& name) const { return getMap().getBool(name); } - catch (UnsupportedOperationException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -329,10 +308,7 @@ unsigned char ActiveMQMapMessage::getByte(const std::string& name) const { return getMap().getByte(name); } - catch (UnsupportedOperationException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -355,10 +331,7 @@ std::vector ActiveMQMapMessage::getBytes( { return getMap().getByteArray(name); } - catch (UnsupportedOperationException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -381,10 +354,7 @@ char ActiveMQMapMessage::getChar(const std::string& name) const { return getMap().getChar(name); } - catch (UnsupportedOperationException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -406,10 +376,7 @@ double ActiveMQMapMessage::getDouble(const std::string& name) const { return getMap().getDouble(name); } - catch (UnsupportedOperationException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -431,10 +398,7 @@ float ActiveMQMapMessage::getFloat(const std::string& name) const { return getMap().getFloat(name); } - catch (UnsupportedOperationException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -456,10 +420,7 @@ int ActiveMQMapMessage::getInt(const std::string& name) const { return getMap().getInt(name); } - catch (UnsupportedOperationException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -481,10 +442,7 @@ long long ActiveMQMapMessage::getLong(const std::string& name) const { return getMap().getLong(name); } - catch (UnsupportedOperationException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -506,10 +464,7 @@ short ActiveMQMapMessage::getShort(const std::string& name) const { return getMap().getShort(name); } - catch (UnsupportedOperationException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -531,10 +486,7 @@ std::string ActiveMQMapMessage::getString(const std::string& name) const { return getMap().getString(name); } - catch (UnsupportedOperationException& ex) - { - throw CMSExceptionSupport::createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.h b/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.h index f7716fa11..abe1bbbff 100644 --- a/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.h +++ b/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.h @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -133,7 +132,7 @@ namespace commands * * @return reference to a PrimtiveMap; * - * @throws NullPointerException if the internal Map is Null. + * @throws std::logic_error if the internal Map is Null. */ util::PrimitiveMap& getMap(); const util::PrimitiveMap& getMap() const; @@ -141,7 +140,7 @@ namespace commands /** * Performs the unmarshal on the Map if needed, otherwise just returns * - * @throws NullPointerException if the internal Map is Null. + * @throws std::logic_error if the internal Map is Null. */ virtual void checkMapIsUnmarshalled() const; }; diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h b/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h index 46b0b085b..d0032d13e 100644 --- a/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h +++ b/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h @@ -21,14 +21,15 @@ #include #include #include +#include #include #include #include #include #include -#include #include +#include #include #include @@ -203,11 +204,7 @@ namespace commands this->ensurePropertiesUnmarshaled(); return this->propertiesInterceptor->getBooleanProperty(name); } - catch (decaf::lang::exceptions::UnsupportedOperationException& ex) - { - throw activemq::util::CMSExceptionSupport:: - createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -220,11 +217,7 @@ namespace commands this->ensurePropertiesUnmarshaled(); return this->propertiesInterceptor->getByteProperty(name); } - catch (decaf::lang::exceptions::UnsupportedOperationException& ex) - { - throw activemq::util::CMSExceptionSupport:: - createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -237,11 +230,7 @@ namespace commands this->ensurePropertiesUnmarshaled(); return this->propertiesInterceptor->getDoubleProperty(name); } - catch (decaf::lang::exceptions::UnsupportedOperationException& ex) - { - throw activemq::util::CMSExceptionSupport:: - createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -254,11 +243,7 @@ namespace commands this->ensurePropertiesUnmarshaled(); return this->propertiesInterceptor->getFloatProperty(name); } - catch (decaf::lang::exceptions::UnsupportedOperationException& ex) - { - throw activemq::util::CMSExceptionSupport:: - createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -271,11 +256,7 @@ namespace commands this->ensurePropertiesUnmarshaled(); return this->propertiesInterceptor->getIntProperty(name); } - catch (decaf::lang::exceptions::UnsupportedOperationException& ex) - { - throw activemq::util::CMSExceptionSupport:: - createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -288,11 +269,7 @@ namespace commands this->ensurePropertiesUnmarshaled(); return this->propertiesInterceptor->getLongProperty(name); } - catch (decaf::lang::exceptions::UnsupportedOperationException& ex) - { - throw activemq::util::CMSExceptionSupport:: - createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -305,11 +282,7 @@ namespace commands this->ensurePropertiesUnmarshaled(); return this->propertiesInterceptor->getShortProperty(name); } - catch (decaf::lang::exceptions::UnsupportedOperationException& ex) - { - throw activemq::util::CMSExceptionSupport:: - createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -322,11 +295,7 @@ namespace commands this->ensurePropertiesUnmarshaled(); return this->propertiesInterceptor->getStringProperty(name); } - catch (decaf::lang::exceptions::UnsupportedOperationException& ex) - { - throw activemq::util::CMSExceptionSupport:: - createMessageFormatException(ex); - } + AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() AMQ_CATCH_ALL_THROW_CMSEXCEPTION() } @@ -556,7 +525,7 @@ namespace commands std::shared_ptr id(new MessageId(value)); this->setMessageId(id); } - catch (decaf::lang::exceptions::NumberFormatException& e) + catch (const std::invalid_argument&) { // we must be some foreign JMS provider or strange user-supplied // String so lets set the IDs to be 1 @@ -564,6 +533,12 @@ namespace commands id->setTextView(value); this->setMessageId(id); } + catch (const ::activemq::exceptions::OutOfRangeException&) + { + std::shared_ptr id(new MessageId); + id->setTextView(value); + this->setMessageId(id); + } } virtual int getCMSPriority() const diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQObjectMessage.cpp b/activemq-cpp/src/main/activemq/commands/ActiveMQObjectMessage.cpp index fb9ac3da8..ac47e2b82 100644 --- a/activemq-cpp/src/main/activemq/commands/ActiveMQObjectMessage.cpp +++ b/activemq-cpp/src/main/activemq/commands/ActiveMQObjectMessage.cpp @@ -34,7 +34,6 @@ using namespace activemq::commands; using namespace activemq::exceptions; using namespace decaf::io; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -148,7 +147,7 @@ std::vector ActiveMQObjectMessage::getObjectBytes() const uncompressed.resize((std::size_t)length); } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { throw CMSExceptionSupport::create(ex); } diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp b/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp index 0014427bb..e0411d425 100644 --- a/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp +++ b/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp @@ -19,14 +19,19 @@ #include #include +#include +#include #include #include #include #include #include +#include +#include #include +#include #include #include #include @@ -39,7 +44,6 @@ #include #include #include -#include #include #include @@ -54,7 +58,6 @@ using namespace activemq::wireformat::openwire; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -153,9 +156,7 @@ void ActiveMQStreamMessage::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "ActiveMQStreamMessage::copyDataStructure - src is NULL or " "invalid"); } @@ -240,9 +241,10 @@ bool ActiveMQStreamMessage::readBoolean() const if (type == PrimitiveValueNode::NULL_TYPE) { this->dataIn->reset(); - throw NullPointerException(__FILE__, - __LINE__, - "Cannot convert NULL value to boolean."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Cannot convert NULL value to boolean."); } else { @@ -250,15 +252,23 @@ bool ActiveMQStreamMessage::readBoolean() const throw MessageFormatException("not a boolean type", NULL); } } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (activemq::exceptions::IllegalStateException& e) + { + throw CMSException(e.what(), NULL); + } + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } @@ -301,9 +311,10 @@ unsigned char ActiveMQStreamMessage::readByte() const if (type == PrimitiveValueNode::NULL_TYPE) { this->dataIn->reset(); - throw NullPointerException(__FILE__, - __LINE__, - "Cannot convert NULL value to byte."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Cannot convert NULL value to byte."); } else { @@ -311,28 +322,36 @@ unsigned char ActiveMQStreamMessage::readByte() const throw MessageFormatException(" not a byte type", NULL); } } - catch (NumberFormatException& ex) + catch (std::invalid_argument& ex) { try { this->dataIn->reset(); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::create(e); } throw CMSExceptionSupport::createMessageFormatException(ex); } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (activemq::exceptions::IllegalStateException& e) + { + throw CMSException(e.what(), NULL); + } + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } @@ -383,9 +402,10 @@ int ActiveMQStreamMessage::readBytes(unsigned char* buffer, int length) const { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Passed buffer was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Passed buffer was NULL"); } if (this->impl->remainingBytes == -1) @@ -429,15 +449,23 @@ int ActiveMQStreamMessage::readBytes(unsigned char* buffer, int length) const return rc; } } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (activemq::exceptions::IllegalStateException& e) + { + throw CMSException(e.what(), NULL); + } + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } @@ -479,9 +507,10 @@ char ActiveMQStreamMessage::readChar() const if (type == PrimitiveValueNode::NULL_TYPE) { this->dataIn->reset(); - throw NullPointerException(__FILE__, - __LINE__, - "Cannot convert NULL value to char."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Cannot convert NULL value to char."); } else { @@ -489,29 +518,36 @@ char ActiveMQStreamMessage::readChar() const throw MessageFormatException(" not a char type", NULL); } } - catch (NumberFormatException& ex) + catch (std::invalid_argument& ex) { try { this->dataIn->reset(); } - catch (IOException& ioe) + catch (activemq::exceptions::IOException& ioe) { throw CMSExceptionSupport::create(ioe); } - throw CMSExceptionSupport::create(ex); - ; + throw CMSExceptionSupport::createMessageFormatException(ex); } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (activemq::exceptions::IllegalStateException& e) + { + throw CMSException(e.what(), NULL); + } + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } @@ -554,9 +590,10 @@ float ActiveMQStreamMessage::readFloat() const if (type == PrimitiveValueNode::NULL_TYPE) { this->dataIn->reset(); - throw NullPointerException(__FILE__, - __LINE__, - "Cannot convert NULL value to float."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Cannot convert NULL value to float."); } else { @@ -564,28 +601,36 @@ float ActiveMQStreamMessage::readFloat() const throw MessageFormatException(" not a float type", NULL); } } - catch (NumberFormatException& ex) + catch (std::invalid_argument& ex) { try { this->dataIn->reset(); } - catch (IOException& ioe) + catch (activemq::exceptions::IOException& ioe) { throw CMSExceptionSupport::create(ioe); } - throw CMSExceptionSupport::create(ex); + throw CMSExceptionSupport::createMessageFormatException(ex); } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (activemq::exceptions::IllegalStateException& e) + { + throw CMSException(e.what(), NULL); + } + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } @@ -632,9 +677,10 @@ double ActiveMQStreamMessage::readDouble() const if (type == PrimitiveValueNode::NULL_TYPE) { this->dataIn->reset(); - throw NullPointerException(__FILE__, - __LINE__, - "Cannot convert NULL value to double."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Cannot convert NULL value to double."); } else { @@ -642,28 +688,36 @@ double ActiveMQStreamMessage::readDouble() const throw MessageFormatException(" not a double type", NULL); } } - catch (NumberFormatException& ex) + catch (std::invalid_argument& ex) { try { this->dataIn->reset(); } - catch (IOException& ioe) + catch (activemq::exceptions::IOException& ioe) { throw CMSExceptionSupport::create(ioe); } - throw CMSExceptionSupport::create(ex); + throw CMSExceptionSupport::createMessageFormatException(ex); } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (activemq::exceptions::IllegalStateException& e) + { + throw CMSException(e.what(), NULL); + } + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } @@ -710,9 +764,10 @@ short ActiveMQStreamMessage::readShort() const if (type == PrimitiveValueNode::NULL_TYPE) { this->dataIn->reset(); - throw NullPointerException(__FILE__, - __LINE__, - "Cannot convert NULL value to short."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Cannot convert NULL value to short."); } else { @@ -720,28 +775,36 @@ short ActiveMQStreamMessage::readShort() const throw MessageFormatException(" not a short type", NULL); } } - catch (NumberFormatException& ex) + catch (std::invalid_argument& ex) { try { this->dataIn->reset(); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::create(e); } - throw CMSExceptionSupport::create(ex); + throw CMSExceptionSupport::createMessageFormatException(ex); } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (activemq::exceptions::IllegalStateException& e) + { + throw CMSException(e.what(), NULL); + } + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } @@ -789,9 +852,10 @@ unsigned short ActiveMQStreamMessage::readUnsignedShort() const if (type == PrimitiveValueNode::NULL_TYPE) { this->dataIn->reset(); - throw NullPointerException(__FILE__, - __LINE__, - "Cannot convert NULL value to short."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Cannot convert NULL value to short."); } else { @@ -799,28 +863,36 @@ unsigned short ActiveMQStreamMessage::readUnsignedShort() const throw MessageFormatException(" not a short type", NULL); } } - catch (NumberFormatException& ex) + catch (std::invalid_argument& ex) { try { this->dataIn->reset(); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::create(e); } - throw CMSExceptionSupport::create(ex); + throw CMSExceptionSupport::createMessageFormatException(ex); } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (activemq::exceptions::IllegalStateException& e) + { + throw CMSException(e.what(), NULL); + } + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } @@ -871,9 +943,10 @@ int ActiveMQStreamMessage::readInt() const if (type == PrimitiveValueNode::NULL_TYPE) { this->dataIn->reset(); - throw NullPointerException(__FILE__, - __LINE__, - "Cannot convert NULL value to int."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Cannot convert NULL value to int."); } else { @@ -881,28 +954,36 @@ int ActiveMQStreamMessage::readInt() const throw MessageFormatException(" not a int type", NULL); } } - catch (NumberFormatException& ex) + catch (std::invalid_argument& ex) { try { this->dataIn->reset(); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::create(e); } - throw CMSExceptionSupport::create(ex); + throw CMSExceptionSupport::createMessageFormatException(ex); } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (activemq::exceptions::IllegalStateException& e) + { + throw CMSException(e.what(), NULL); + } + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } @@ -957,9 +1038,10 @@ long long ActiveMQStreamMessage::readLong() const if (type == PrimitiveValueNode::NULL_TYPE) { this->dataIn->reset(); - throw NullPointerException(__FILE__, - __LINE__, - "Cannot convert NULL value to long."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Cannot convert NULL value to long."); } else { @@ -967,28 +1049,36 @@ long long ActiveMQStreamMessage::readLong() const throw MessageFormatException(" not a long type", NULL); } } - catch (NumberFormatException& ex) + catch (std::invalid_argument& ex) { try { this->dataIn->reset(); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::create(e); } - throw CMSExceptionSupport::create(ex); + throw CMSExceptionSupport::createMessageFormatException(ex); } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (activemq::exceptions::IllegalStateException& e) + { + throw CMSException(e.what(), NULL); + } + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } @@ -1072,28 +1162,32 @@ std::string ActiveMQStreamMessage::readString() const throw MessageFormatException(" not a String type", NULL); } } - catch (NumberFormatException& ex) + catch (std::invalid_argument& ex) { try { this->dataIn->reset(); } - catch (IOException& ioe) + catch (activemq::exceptions::IOException& ioe) { throw CMSExceptionSupport::create(ioe); } - throw CMSExceptionSupport::create(ex); + throw CMSExceptionSupport::createMessageFormatException(ex); } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } @@ -1165,15 +1259,19 @@ cms::Message::ValueType ActiveMQStreamMessage::getNextValueType() const return cms::Message::UNKNOWN_TYPE; } - catch (EOFException& e) + catch (activemq::exceptions::EOFException& e) { throw CMSExceptionSupport::createMessageEOFException(e); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { throw CMSExceptionSupport::createMessageFormatException(e); } - catch (Exception& e) + catch (cms::CMSException&) + { + throw; + } + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.h b/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.h index 06899766a..88354434a 100644 --- a/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.h +++ b/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp b/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp index faa5c1ee1..4eba8299b 100644 --- a/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp +++ b/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp @@ -23,9 +23,11 @@ #include #include +#include #include #include #include +#include using namespace std; using namespace activemq; @@ -92,7 +94,7 @@ void ActiveMQTextMessage::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ActiveMQTextMessage::copyDataStructure - src is NULL or invalid"); @@ -232,7 +234,7 @@ std::string ActiveMQTextMessage::getText() const dataIn.close(); } - catch (IOException& ioe) + catch (activemq::exceptions::IOException& ioe) { throw CMSExceptionSupport::create(ioe); } diff --git a/activemq-cpp/src/main/activemq/commands/BrokerError.cpp b/activemq-cpp/src/main/activemq/commands/BrokerError.cpp index 1409dce83..79447d5a5 100644 --- a/activemq-cpp/src/main/activemq/commands/BrokerError.cpp +++ b/activemq-cpp/src/main/activemq/commands/BrokerError.cpp @@ -16,10 +16,11 @@ */ #include #include +#include #include -#include #include #include +#include #include #include @@ -43,7 +44,6 @@ using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; using namespace decaf::util; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// BrokerError::BrokerError() @@ -80,9 +80,7 @@ void BrokerError::copyDataStructure(const DataStructure* src) if (srcErr == NULL || src == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "BrokerError::copyCommand - src is NULL or invalid"); } diff --git a/activemq-cpp/src/main/activemq/commands/BrokerId.cpp b/activemq-cpp/src/main/activemq/commands/BrokerId.cpp index c8ecd6293..7b53853bb 100644 --- a/activemq-cpp/src/main/activemq/commands/BrokerId.cpp +++ b/activemq-cpp/src/main/activemq/commands/BrokerId.cpp @@ -17,16 +17,16 @@ #include #include +#include #include #include -#include #include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; using namespace decaf::internal::util; /* @@ -83,7 +83,7 @@ void BrokerId::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "BrokerId::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/BrokerInfo.cpp b/activemq-cpp/src/main/activemq/commands/BrokerInfo.cpp index 531fb1f4c..b45dac44a 100644 --- a/activemq-cpp/src/main/activemq/commands/BrokerInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/BrokerInfo.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for BrokerInfo @@ -84,7 +83,7 @@ void BrokerInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "BrokerInfo::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ConnectionControl.cpp b/activemq-cpp/src/main/activemq/commands/ConnectionControl.cpp index 0cb360bf4..623ef3574 100644 --- a/activemq-cpp/src/main/activemq/commands/ConnectionControl.cpp +++ b/activemq-cpp/src/main/activemq/commands/ConnectionControl.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for ConnectionControl @@ -83,7 +82,7 @@ void ConnectionControl::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ConnectionControl::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ConnectionError.cpp b/activemq-cpp/src/main/activemq/commands/ConnectionError.cpp index cc563b86e..b15618b69 100644 --- a/activemq-cpp/src/main/activemq/commands/ConnectionError.cpp +++ b/activemq-cpp/src/main/activemq/commands/ConnectionError.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for ConnectionError @@ -74,7 +73,7 @@ void ConnectionError::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ConnectionError::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ConnectionId.cpp b/activemq-cpp/src/main/activemq/commands/ConnectionId.cpp index e6af22bdb..de11234cf 100644 --- a/activemq-cpp/src/main/activemq/commands/ConnectionId.cpp +++ b/activemq-cpp/src/main/activemq/commands/ConnectionId.cpp @@ -20,17 +20,17 @@ #include #include #include +#include #include #include -#include #include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; using namespace decaf::internal::util; /* @@ -111,7 +111,7 @@ void ConnectionId::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ConnectionId::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ConnectionInfo.cpp b/activemq-cpp/src/main/activemq/commands/ConnectionInfo.cpp index d5acdad0a..df575882f 100644 --- a/activemq-cpp/src/main/activemq/commands/ConnectionInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/ConnectionInfo.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for ConnectionInfo @@ -83,7 +82,7 @@ void ConnectionInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ConnectionInfo::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ConsumerControl.cpp b/activemq-cpp/src/main/activemq/commands/ConsumerControl.cpp index 7086fb49e..b92f6e3d7 100644 --- a/activemq-cpp/src/main/activemq/commands/ConsumerControl.cpp +++ b/activemq-cpp/src/main/activemq/commands/ConsumerControl.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for ConsumerControl @@ -79,7 +78,7 @@ void ConsumerControl::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ConsumerControl::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ConsumerId.cpp b/activemq-cpp/src/main/activemq/commands/ConsumerId.cpp index 82137bfbb..b1de4946d 100644 --- a/activemq-cpp/src/main/activemq/commands/ConsumerId.cpp +++ b/activemq-cpp/src/main/activemq/commands/ConsumerId.cpp @@ -17,18 +17,18 @@ #include #include +#include #include #include -#include #include #include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; using namespace decaf::internal::util; /* @@ -104,7 +104,7 @@ void ConsumerId::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ConsumerId::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ConsumerInfo.cpp b/activemq-cpp/src/main/activemq/commands/ConsumerInfo.cpp index a4ef55255..e53d75c03 100644 --- a/activemq-cpp/src/main/activemq/commands/ConsumerInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/ConsumerInfo.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for ConsumerInfo @@ -91,7 +90,7 @@ void ConsumerInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ConsumerInfo::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ControlCommand.cpp b/activemq-cpp/src/main/activemq/commands/ControlCommand.cpp index fa1baf07e..09eae8ffb 100644 --- a/activemq-cpp/src/main/activemq/commands/ControlCommand.cpp +++ b/activemq-cpp/src/main/activemq/commands/ControlCommand.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for ControlCommand @@ -73,7 +72,7 @@ void ControlCommand::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ControlCommand::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/DataArrayResponse.cpp b/activemq-cpp/src/main/activemq/commands/DataArrayResponse.cpp index d1b69716e..4fba1fa8d 100644 --- a/activemq-cpp/src/main/activemq/commands/DataArrayResponse.cpp +++ b/activemq-cpp/src/main/activemq/commands/DataArrayResponse.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for DataArrayResponse @@ -75,7 +74,7 @@ void DataArrayResponse::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "DataArrayResponse::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/DataResponse.cpp b/activemq-cpp/src/main/activemq/commands/DataResponse.cpp index 21340402e..f2e6190a3 100644 --- a/activemq-cpp/src/main/activemq/commands/DataResponse.cpp +++ b/activemq-cpp/src/main/activemq/commands/DataResponse.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for DataResponse @@ -73,7 +72,7 @@ void DataResponse::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "DataResponse::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/DestinationInfo.cpp b/activemq-cpp/src/main/activemq/commands/DestinationInfo.cpp index d3ab3439b..1cd39bfc3 100644 --- a/activemq-cpp/src/main/activemq/commands/DestinationInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/DestinationInfo.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for DestinationInfo @@ -77,7 +76,7 @@ void DestinationInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "DestinationInfo::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/DiscoveryEvent.cpp b/activemq-cpp/src/main/activemq/commands/DiscoveryEvent.cpp index cb7c4f9c4..8c229f379 100644 --- a/activemq-cpp/src/main/activemq/commands/DiscoveryEvent.cpp +++ b/activemq-cpp/src/main/activemq/commands/DiscoveryEvent.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for DiscoveryEvent @@ -74,7 +73,7 @@ void DiscoveryEvent::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "DiscoveryEvent::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ExceptionResponse.cpp b/activemq-cpp/src/main/activemq/commands/ExceptionResponse.cpp index a50dfbde4..74e52c6fe 100644 --- a/activemq-cpp/src/main/activemq/commands/ExceptionResponse.cpp +++ b/activemq-cpp/src/main/activemq/commands/ExceptionResponse.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for ExceptionResponse @@ -75,7 +74,7 @@ void ExceptionResponse::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ExceptionResponse::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/FlushCommand.cpp b/activemq-cpp/src/main/activemq/commands/FlushCommand.cpp index 28302c497..953b7b197 100644 --- a/activemq-cpp/src/main/activemq/commands/FlushCommand.cpp +++ b/activemq-cpp/src/main/activemq/commands/FlushCommand.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for FlushCommand @@ -72,7 +71,7 @@ void FlushCommand::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "FlushCommand::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/IntegerResponse.cpp b/activemq-cpp/src/main/activemq/commands/IntegerResponse.cpp index eb521352c..c3c1358e5 100644 --- a/activemq-cpp/src/main/activemq/commands/IntegerResponse.cpp +++ b/activemq-cpp/src/main/activemq/commands/IntegerResponse.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for IntegerResponse @@ -73,7 +72,7 @@ void IntegerResponse::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "IntegerResponse::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/JournalQueueAck.cpp b/activemq-cpp/src/main/activemq/commands/JournalQueueAck.cpp index 6fc57d664..fe30c849c 100644 --- a/activemq-cpp/src/main/activemq/commands/JournalQueueAck.cpp +++ b/activemq-cpp/src/main/activemq/commands/JournalQueueAck.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for JournalQueueAck @@ -74,7 +73,7 @@ void JournalQueueAck::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "JournalQueueAck::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/JournalTopicAck.cpp b/activemq-cpp/src/main/activemq/commands/JournalTopicAck.cpp index 6a760ea17..ab520a81b 100644 --- a/activemq-cpp/src/main/activemq/commands/JournalTopicAck.cpp +++ b/activemq-cpp/src/main/activemq/commands/JournalTopicAck.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for JournalTopicAck @@ -78,7 +77,7 @@ void JournalTopicAck::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "JournalTopicAck::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/JournalTrace.cpp b/activemq-cpp/src/main/activemq/commands/JournalTrace.cpp index 68d12145c..72ad7b834 100644 --- a/activemq-cpp/src/main/activemq/commands/JournalTrace.cpp +++ b/activemq-cpp/src/main/activemq/commands/JournalTrace.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for JournalTrace @@ -73,7 +72,7 @@ void JournalTrace::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "JournalTrace::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/JournalTransaction.cpp b/activemq-cpp/src/main/activemq/commands/JournalTransaction.cpp index da58e0fd1..a888d66e5 100644 --- a/activemq-cpp/src/main/activemq/commands/JournalTransaction.cpp +++ b/activemq-cpp/src/main/activemq/commands/JournalTransaction.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for JournalTransaction @@ -77,7 +76,7 @@ void JournalTransaction::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "JournalTransaction::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/KeepAliveInfo.cpp b/activemq-cpp/src/main/activemq/commands/KeepAliveInfo.cpp index 7ab40a86e..9af34a0ef 100644 --- a/activemq-cpp/src/main/activemq/commands/KeepAliveInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/KeepAliveInfo.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for KeepAliveInfo @@ -72,7 +71,7 @@ void KeepAliveInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "KeepAliveInfo::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/LastPartialCommand.cpp b/activemq-cpp/src/main/activemq/commands/LastPartialCommand.cpp index 34d23b789..36162d57a 100644 --- a/activemq-cpp/src/main/activemq/commands/LastPartialCommand.cpp +++ b/activemq-cpp/src/main/activemq/commands/LastPartialCommand.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for LastPartialCommand @@ -74,7 +73,7 @@ void LastPartialCommand::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "LastPartialCommand::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/LocalTransactionId.cpp b/activemq-cpp/src/main/activemq/commands/LocalTransactionId.cpp index a36a8febd..b1930f382 100644 --- a/activemq-cpp/src/main/activemq/commands/LocalTransactionId.cpp +++ b/activemq-cpp/src/main/activemq/commands/LocalTransactionId.cpp @@ -17,17 +17,17 @@ #include #include +#include #include #include -#include #include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; using namespace decaf::internal::util; /* @@ -88,7 +88,7 @@ void LocalTransactionId::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "LocalTransactionId::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/Message.cpp b/activemq-cpp/src/main/activemq/commands/Message.cpp index 314eb5c91..22858a1b5 100644 --- a/activemq-cpp/src/main/activemq/commands/Message.cpp +++ b/activemq-cpp/src/main/activemq/commands/Message.cpp @@ -19,18 +19,20 @@ #include #include #include +#include +#include #include #include #include #include -#include +#include #include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; /* * @@ -113,7 +115,7 @@ void Message::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Message::copyDataStructure - src is NULL or invalid"); @@ -1161,9 +1163,9 @@ void Message::beforeMarshal(wireformat::WireFormat* wireFormat AMQCPP_UNUSED) marshalledProperties); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -1211,7 +1213,7 @@ void Message::ensurePropertiesUnmarshaled() const const_cast&>(marshalledProperties)); propertiesUnmarshaled = true; } - catch (decaf::io::IOException& e) + catch (activemq::exceptions::IOException& e) { AMQ_LOG_ERROR( "Message", @@ -1223,8 +1225,7 @@ void Message::ensurePropertiesUnmarshaled() const << ", exception=" << e.getMessage()); throw; } - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } } diff --git a/activemq-cpp/src/main/activemq/commands/MessageAck.cpp b/activemq-cpp/src/main/activemq/commands/MessageAck.cpp index a4d919735..c2eb5bcfc 100644 --- a/activemq-cpp/src/main/activemq/commands/MessageAck.cpp +++ b/activemq-cpp/src/main/activemq/commands/MessageAck.cpp @@ -18,16 +18,15 @@ #include #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for MessageAck @@ -122,7 +121,7 @@ void MessageAck::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "MessageAck::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/MessageDispatch.cpp b/activemq-cpp/src/main/activemq/commands/MessageDispatch.cpp index 4be92074d..35379bdf5 100644 --- a/activemq-cpp/src/main/activemq/commands/MessageDispatch.cpp +++ b/activemq-cpp/src/main/activemq/commands/MessageDispatch.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for MessageDispatch @@ -77,7 +76,7 @@ void MessageDispatch::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "MessageDispatch::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/MessageDispatchNotification.cpp b/activemq-cpp/src/main/activemq/commands/MessageDispatchNotification.cpp index d162e2648..1628e8325 100644 --- a/activemq-cpp/src/main/activemq/commands/MessageDispatchNotification.cpp +++ b/activemq-cpp/src/main/activemq/commands/MessageDispatchNotification.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for MessageDispatchNotification @@ -79,7 +78,7 @@ void MessageDispatchNotification::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "MessageDispatchNotification::copyDataStructure - src is NULL or " diff --git a/activemq-cpp/src/main/activemq/commands/MessageId.cpp b/activemq-cpp/src/main/activemq/commands/MessageId.cpp index 26b408ae7..e53b632f7 100644 --- a/activemq-cpp/src/main/activemq/commands/MessageId.cpp +++ b/activemq-cpp/src/main/activemq/commands/MessageId.cpp @@ -17,10 +17,9 @@ #include #include +#include #include #include -#include -#include #include #include #include @@ -30,7 +29,6 @@ using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; using namespace decaf::internal::util; /* @@ -149,9 +147,7 @@ void MessageId::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::TypeMismatchException( "MessageId::copyDataStructure - src is NULL or invalid"); } @@ -377,33 +373,25 @@ int MessageId::getHashCode() const //////////////////////////////////////////////////////////////////////////////// void MessageId::setValue(const std::string& key) { - std::string messageKey = key; + try + { + std::string messageKey = key; - // Parse off the sequenceId - std::size_t p = messageKey.rfind(':'); + // Parse off the sequenceId + std::size_t p = messageKey.rfind(':'); - if (p != std::string::npos) - { - try + if (p != std::string::npos) { producerSequenceId = std::stoll(messageKey.substr(p + 1, std::string::npos)); + messageKey = messageKey.substr(0, p); } - catch (const std::invalid_argument& e) - { - throw decaf::lang::exceptions::NumberFormatException(__FILE__, - __LINE__, - e.what()); - } - catch (const std::out_of_range& e) - { - throw decaf::lang::exceptions::NumberFormatException(__FILE__, - __LINE__, - e.what()); - } - messageKey = messageKey.substr(0, p); - } - this->producerId.reset(new ProducerId(messageKey)); - this->key = messageKey; + this->producerId.reset(new ProducerId(messageKey)); + this->key = messageKey; + } + catch (const std::out_of_range& ex) + { + throw OutOfRangeException(__FILE__, __LINE__, ex.what()); + } } diff --git a/activemq-cpp/src/main/activemq/commands/MessagePull.cpp b/activemq-cpp/src/main/activemq/commands/MessagePull.cpp index fd6307dd4..a2302f164 100644 --- a/activemq-cpp/src/main/activemq/commands/MessagePull.cpp +++ b/activemq-cpp/src/main/activemq/commands/MessagePull.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for MessagePull @@ -77,7 +76,7 @@ void MessagePull::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "MessagePull::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/NetworkBridgeFilter.cpp b/activemq-cpp/src/main/activemq/commands/NetworkBridgeFilter.cpp index 636d5490c..58fcf309e 100644 --- a/activemq-cpp/src/main/activemq/commands/NetworkBridgeFilter.cpp +++ b/activemq-cpp/src/main/activemq/commands/NetworkBridgeFilter.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for NetworkBridgeFilter @@ -77,7 +76,7 @@ void NetworkBridgeFilter::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "NetworkBridgeFilter::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/PartialCommand.cpp b/activemq-cpp/src/main/activemq/commands/PartialCommand.cpp index 692a39c40..825a7daea 100644 --- a/activemq-cpp/src/main/activemq/commands/PartialCommand.cpp +++ b/activemq-cpp/src/main/activemq/commands/PartialCommand.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for PartialCommand @@ -74,7 +73,7 @@ void PartialCommand::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "PartialCommand::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ProducerAck.cpp b/activemq-cpp/src/main/activemq/commands/ProducerAck.cpp index b1b37e577..ab08bd6a4 100644 --- a/activemq-cpp/src/main/activemq/commands/ProducerAck.cpp +++ b/activemq-cpp/src/main/activemq/commands/ProducerAck.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for ProducerAck @@ -74,7 +73,7 @@ void ProducerAck::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ProducerAck::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ProducerId.cpp b/activemq-cpp/src/main/activemq/commands/ProducerId.cpp index 4590c0509..d0c32a2e2 100644 --- a/activemq-cpp/src/main/activemq/commands/ProducerId.cpp +++ b/activemq-cpp/src/main/activemq/commands/ProducerId.cpp @@ -17,10 +17,9 @@ #include #include +#include #include #include -#include -#include #include #include #include @@ -30,7 +29,6 @@ using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; using namespace decaf::internal::util; /* @@ -90,22 +88,7 @@ ProducerId::ProducerId(std::string producerKey) if (p != std::string::npos) { - try - { - value = std::stoll(producerKey.substr(p + 1, std::string::npos)); - } - catch (const std::invalid_argument& e) - { - throw decaf::lang::exceptions::NumberFormatException(__FILE__, - __LINE__, - e.what()); - } - catch (const std::out_of_range& e) - { - throw decaf::lang::exceptions::NumberFormatException(__FILE__, - __LINE__, - e.what()); - } + value = std::stoll(producerKey.substr(p + 1, std::string::npos)); producerKey = producerKey.substr(0, p); } @@ -141,9 +124,7 @@ void ProducerId::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::TypeMismatchException( "ProducerId::copyDataStructure - src is NULL or invalid"); } @@ -334,23 +315,8 @@ void ProducerId::setProducerSessionKey(std::string sessionKey) if (p != std::string::npos) { - try - { - this->sessionId = - std::stoll(sessionKey.substr(p + 1, std::string::npos)); - } - catch (const std::invalid_argument& e) - { - throw decaf::lang::exceptions::NumberFormatException(__FILE__, - __LINE__, - e.what()); - } - catch (const std::out_of_range& e) - { - throw decaf::lang::exceptions::NumberFormatException(__FILE__, - __LINE__, - e.what()); - } + this->sessionId = + std::stoll(sessionKey.substr(p + 1, std::string::npos)); sessionKey = sessionKey.substr(0, p); } diff --git a/activemq-cpp/src/main/activemq/commands/ProducerInfo.cpp b/activemq-cpp/src/main/activemq/commands/ProducerInfo.cpp index d82915e34..e2507b16e 100644 --- a/activemq-cpp/src/main/activemq/commands/ProducerInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/ProducerInfo.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for ProducerInfo @@ -77,7 +76,7 @@ void ProducerInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ProducerInfo::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/RemoveInfo.cpp b/activemq-cpp/src/main/activemq/commands/RemoveInfo.cpp index ef39ff0df..dc1c068e7 100644 --- a/activemq-cpp/src/main/activemq/commands/RemoveInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/RemoveInfo.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for RemoveInfo @@ -74,7 +73,7 @@ void RemoveInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "RemoveInfo::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/RemoveSubscriptionInfo.cpp b/activemq-cpp/src/main/activemq/commands/RemoveSubscriptionInfo.cpp index dc5d725f7..ffadbe138 100644 --- a/activemq-cpp/src/main/activemq/commands/RemoveSubscriptionInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/RemoveSubscriptionInfo.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for RemoveSubscriptionInfo @@ -77,7 +76,7 @@ void RemoveSubscriptionInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "RemoveSubscriptionInfo::copyDataStructure - src is NULL or " diff --git a/activemq-cpp/src/main/activemq/commands/ReplayCommand.cpp b/activemq-cpp/src/main/activemq/commands/ReplayCommand.cpp index 60b373c90..79bd9ec38 100644 --- a/activemq-cpp/src/main/activemq/commands/ReplayCommand.cpp +++ b/activemq-cpp/src/main/activemq/commands/ReplayCommand.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for ReplayCommand @@ -74,7 +73,7 @@ void ReplayCommand::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ReplayCommand::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/Response.cpp b/activemq-cpp/src/main/activemq/commands/Response.cpp index d75c2d104..d6a3a28a0 100644 --- a/activemq-cpp/src/main/activemq/commands/Response.cpp +++ b/activemq-cpp/src/main/activemq/commands/Response.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for Response @@ -73,7 +72,7 @@ void Response::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Response::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/SessionId.cpp b/activemq-cpp/src/main/activemq/commands/SessionId.cpp index ea284cd14..552593ffc 100644 --- a/activemq-cpp/src/main/activemq/commands/SessionId.cpp +++ b/activemq-cpp/src/main/activemq/commands/SessionId.cpp @@ -20,18 +20,18 @@ #include #include #include +#include #include #include -#include #include #include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; using namespace decaf::internal::util; /* @@ -125,7 +125,7 @@ void SessionId::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "SessionId::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/SessionInfo.cpp b/activemq-cpp/src/main/activemq/commands/SessionInfo.cpp index 20187c06a..daf40c54c 100644 --- a/activemq-cpp/src/main/activemq/commands/SessionInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/SessionInfo.cpp @@ -17,17 +17,16 @@ #include #include +#include #include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for SessionInfo @@ -75,7 +74,7 @@ void SessionInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "SessionInfo::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/ShutdownInfo.cpp b/activemq-cpp/src/main/activemq/commands/ShutdownInfo.cpp index bf7442a29..605339fbf 100644 --- a/activemq-cpp/src/main/activemq/commands/ShutdownInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/ShutdownInfo.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for ShutdownInfo @@ -72,7 +71,7 @@ void ShutdownInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ShutdownInfo::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/SubscriptionInfo.cpp b/activemq-cpp/src/main/activemq/commands/SubscriptionInfo.cpp index 9bac065ea..24f357437 100644 --- a/activemq-cpp/src/main/activemq/commands/SubscriptionInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/SubscriptionInfo.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for SubscriptionInfo @@ -78,7 +77,7 @@ void SubscriptionInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "SubscriptionInfo::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/TransactionId.cpp b/activemq-cpp/src/main/activemq/commands/TransactionId.cpp index b40cbb37e..fb6ec30eb 100644 --- a/activemq-cpp/src/main/activemq/commands/TransactionId.cpp +++ b/activemq-cpp/src/main/activemq/commands/TransactionId.cpp @@ -17,17 +17,17 @@ #include #include +#include #include #include -#include #include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; using namespace decaf::internal::util; /* @@ -82,7 +82,7 @@ void TransactionId::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "TransactionId::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/TransactionInfo.cpp b/activemq-cpp/src/main/activemq/commands/TransactionInfo.cpp index 00fed22f6..7cf9ad1f8 100644 --- a/activemq-cpp/src/main/activemq/commands/TransactionInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/TransactionInfo.cpp @@ -17,16 +17,15 @@ #include #include +#include #include -#include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - /* * * Command code for OpenWire format for TransactionInfo @@ -75,7 +74,7 @@ void TransactionInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "TransactionInfo::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/commands/WireFormatInfo.cpp b/activemq-cpp/src/main/activemq/commands/WireFormatInfo.cpp index 25fdc642c..4e53caa72 100644 --- a/activemq-cpp/src/main/activemq/commands/WireFormatInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/WireFormatInfo.cpp @@ -17,14 +17,15 @@ #include +#include +#include #include #include -#include +#include using namespace std; using namespace decaf; -using namespace decaf::lang::exceptions; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::wireformat; @@ -77,7 +78,7 @@ void WireFormatInfo::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "WireFormatInfo::copyDataStructure - src is NULL or invalid"); @@ -359,10 +360,9 @@ void WireFormatInfo::beforeMarshal(WireFormat* wireFormat AMQCPP_UNUSED) marshalledProperties); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -373,10 +373,9 @@ void WireFormatInfo::afterUnmarshal(WireFormat* wireFormat AMQCPP_UNUSED) marshal::PrimitiveTypesMarshaller::unmarshal(&properties, marshalledProperties); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/commands/XATransactionId.cpp b/activemq-cpp/src/main/activemq/commands/XATransactionId.cpp index e8298c9d5..84930ea79 100644 --- a/activemq-cpp/src/main/activemq/commands/XATransactionId.cpp +++ b/activemq-cpp/src/main/activemq/commands/XATransactionId.cpp @@ -17,18 +17,18 @@ #include #include +#include #include #include #include -#include #include +#include using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; -using namespace decaf::lang::exceptions; using namespace decaf::internal::util; /* @@ -135,7 +135,7 @@ void XATransactionId::copyDataStructure(const DataStructure* src) if (srcPtr == NULL || src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "XATransactionId::copyDataStructure - src is NULL or invalid"); diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp index 0d10e2209..bdc9865cd 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp +++ b/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp @@ -56,6 +56,9 @@ #include #include #include +#include + +#include #include #include @@ -74,6 +77,80 @@ #include #include #include +#include +#include +#include + +namespace +{ +template +[[noreturn]] void throwWrappedActiveMQExceptionFromStl(const E& ex) +{ + activemq::exceptions::ActiveMQException amqEx(__FILE__, + __LINE__, + ex.what()); + amqEx.setMark(__FILE__, __LINE__); + throw amqEx; +} +} // namespace + +#define AMQ_CATCH_STL_BACKED_WRAP_TO_ACTIVEMQ_EXCEPTION() \ + catch (::activemq::exceptions::IllegalStateException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::InvalidStateException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::CloneNotSupportedException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::NullPointerException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::UnsupportedOperationException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::IllegalMonitorStateException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::TypeMismatchException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::OutOfRangeException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::InvalidArgumentException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::InterruptedException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::RuntimeException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::ConcurrentModificationException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::NoSuchElementException & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } \ + catch (::activemq::exceptions::OutOfMemoryError & ex) \ + { \ + throwWrappedActiveMQExceptionFromStl(ex); \ + } using namespace std; using namespace cms; @@ -93,7 +170,6 @@ using namespace decaf::io; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace activemq @@ -112,9 +188,10 @@ namespace core { if (connectionId.empty()) { - throw NullPointerException(__FILE__, - __LINE__, - "Connection Id must be set."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Connection Id must be set."); } } @@ -391,7 +468,7 @@ namespace core error->getException()->createExceptionObject()); } } - catch (Exception& ex) + catch (const std::exception&) { } } @@ -441,9 +518,6 @@ namespace core } } } - catch (Exception& ex) - { - } catch (const std::exception&) { } @@ -527,7 +601,7 @@ namespace core } } } - catch (Exception& ex) + catch (const std::exception&) { } } @@ -729,7 +803,7 @@ void ActiveMQConnection::addSession( this->config->activeSessions.add(session); this->config->sessionsLock.writeLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->sessionsLock.writeLock().unlock(); throw; @@ -751,7 +825,7 @@ void ActiveMQConnection::removeSession( this->config->connectionAudit.removeDispatcher(session.get()); this->config->sessionsLock.writeLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->sessionsLock.writeLock().unlock(); throw; @@ -890,11 +964,23 @@ void ActiveMQConnection::close() { this->config->scheduler->stop(); } - catch (Exception& error) + catch (const std::exception& error) { if (!hasException) { - ex = error; + const Exception* dex = + dynamic_cast(&error); + if (dex != nullptr) + { + ex = *dex; + } + else + { + ex = ActiveMQException(__FILE__, + __LINE__, + "%s", + error.what()); + } ex.setMark(__FILE__, __LINE__); hasException = true; } @@ -934,12 +1020,23 @@ void ActiveMQConnection::close() this->config->activeSessions.clear(); this->config->sessionsLock.writeLock().unlock(); } - catch (Exception& error) + catch (const std::exception& error) { this->config->sessionsLock.writeLock().unlock(); if (!hasException) { - ex = error; + const Exception* dex = dynamic_cast(&error); + if (dex != nullptr) + { + ex = *dex; + } + else + { + ex = ActiveMQException(__FILE__, + __LINE__, + "%s", + error.what()); + } ex.setMark(__FILE__, __LINE__); hasException = true; } @@ -983,11 +1080,22 @@ void ActiveMQConnection::close() this->config->executor->shutdown(); } } - catch (Exception& error) + catch (const std::exception& error) { if (!hasException) { - ex = error; + const Exception* dex = dynamic_cast(&error); + if (dex != nullptr) + { + ex = *dex; + } + else + { + ex = ActiveMQException(__FILE__, + __LINE__, + "%s", + error.what()); + } ex.setMark(__FILE__, __LINE__); hasException = true; } @@ -998,11 +1106,22 @@ void ActiveMQConnection::close() { this->disconnect(lastDeliveredSequenceId); } - catch (Exception& error) + catch (const std::exception& error) { if (!hasException) { - ex = error; + const Exception* dex = dynamic_cast(&error); + if (dex != nullptr) + { + ex = *dex; + } + else + { + ex = ActiveMQException(__FILE__, + __LINE__, + "%s", + error.what()); + } ex.setMark(__FILE__, __LINE__); hasException = true; } @@ -1054,7 +1173,7 @@ void ActiveMQConnection::cleanup() this->config->activeSessions.clear(); this->config->sessionsLock.writeLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->sessionsLock.writeLock().unlock(); throw; @@ -1115,7 +1234,7 @@ void ActiveMQConnection::start() this->config->sessionsLock.readLock().unlock(); } } - catch (Exception& ex) + catch (const std::exception&) { this->config->sessionsLock.readLock().unlock(); throw; @@ -1153,7 +1272,7 @@ void ActiveMQConnection::stop() this->config->sessionsLock.readLock().unlock(); } } - catch (Exception& ex) + catch (const std::exception&) { this->config->sessionsLock.readLock().unlock(); throw; @@ -1271,9 +1390,10 @@ void ActiveMQConnection::destroyDestination( { if (destination == nullptr) { - throw NullPointerException(__FILE__, - __LINE__, - "Destination passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Destination passed was NULL"); } checkClosedOrFailed(); @@ -1291,8 +1411,7 @@ void ActiveMQConnection::destroyDestination( // Send the message to the broker. syncRequest(command); } - AMQ_CATCH_RETHROW(NullPointerException) - AMQ_CATCH_RETHROW(decaf::lang::exceptions::IllegalStateException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() AMQ_CATCH_RETHROW(ActiveMQException) AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) AMQ_CATCHALL_THROW(ActiveMQException) @@ -1305,9 +1424,10 @@ void ActiveMQConnection::destroyDestination(const cms::Destination* destination) { if (destination == nullptr) { - throw NullPointerException(__FILE__, - __LINE__, - "Destination passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Destination passed was NULL"); } checkClosedOrFailed(); @@ -1318,8 +1438,7 @@ void ActiveMQConnection::destroyDestination(const cms::Destination* destination) this->destroyDestination(amqDestination); } - AMQ_CATCH_RETHROW(NullPointerException) - AMQ_CATCH_RETHROW(decaf::lang::exceptions::IllegalStateException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() AMQ_CATCH_RETHROW(ActiveMQException) AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) AMQ_CATCHALL_THROW(ActiveMQException) @@ -1487,7 +1606,7 @@ void ActiveMQConnection::onConsumerControl( } this->config->sessionsLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->sessionsLock.readLock().unlock(); throw; @@ -1563,7 +1682,7 @@ void ActiveMQConnection::transportInterrupted() } this->config->sessionsLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->sessionsLock.readLock().unlock(); throw; @@ -1619,10 +1738,9 @@ void ActiveMQConnection::oneway(std::shared_ptr command) checkClosedOrFailed(); this->config->transport->oneway(command); } - AMQ_CATCH_EXCEPTION_CONVERT(IOException, ActiveMQException) - AMQ_CATCH_EXCEPTION_CONVERT( - decaf::lang::exceptions::UnsupportedOperationException, - ActiveMQException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::IOException, + ActiveMQException) + AMQ_CATCH_STL_BACKED_WRAP_TO_ACTIVEMQ_EXCEPTION() AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) AMQ_CATCHALL_THROW(ActiveMQException) } @@ -1659,7 +1777,7 @@ std::shared_ptr ActiveMQConnection::syncRequest( << AMQLogger::commandTypeName( response->getDataStructureType())); } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { AMQ_LOG_ERROR("ActiveMQConnection", "syncRequest() IOException: " << ex.getMessage()); @@ -1688,10 +1806,9 @@ std::shared_ptr ActiveMQConnection::syncRequest( return response; } AMQ_CATCH_RETHROW(ActiveMQException) - AMQ_CATCH_EXCEPTION_CONVERT(IOException, ActiveMQException) - AMQ_CATCH_EXCEPTION_CONVERT( - decaf::lang::exceptions::UnsupportedOperationException, - ActiveMQException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::IOException, + ActiveMQException) + AMQ_CATCH_STL_BACKED_WRAP_TO_ACTIVEMQ_EXCEPTION() AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) AMQ_CATCHALL_THROW(ActiveMQException) } @@ -1715,10 +1832,9 @@ void ActiveMQConnection::asyncRequest(std::shared_ptr command, this->config->transport->asyncRequest(command, callback); } AMQ_CATCH_RETHROW(ActiveMQException) - AMQ_CATCH_EXCEPTION_CONVERT(IOException, ActiveMQException) - AMQ_CATCH_EXCEPTION_CONVERT( - decaf::lang::exceptions::UnsupportedOperationException, - ActiveMQException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::IOException, + ActiveMQException) + AMQ_CATCH_STL_BACKED_WRAP_TO_ACTIVEMQ_EXCEPTION() AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) AMQ_CATCHALL_THROW(ActiveMQException) } @@ -2233,7 +2349,7 @@ ActiveMQConnection::getSessions() const result.addAll(this->config->activeSessions); this->config->sessionsLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->sessionsLock.readLock().unlock(); throw; @@ -2424,9 +2540,10 @@ void ActiveMQConnection::deleteTempDestination( { if (destination == nullptr) { - throw NullPointerException(__FILE__, - __LINE__, - "Destination passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Destination passed was NULL"); } checkClosedOrFailed(); @@ -2452,7 +2569,7 @@ void ActiveMQConnection::deleteTempDestination( } this->config->sessionsLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->sessionsLock.readLock().unlock(); throw; @@ -2472,8 +2589,7 @@ void ActiveMQConnection::deleteTempDestination( // Send the message to the broker. syncRequest(command); } - AMQ_CATCH_RETHROW(NullPointerException) - AMQ_CATCH_RETHROW(decaf::lang::exceptions::IllegalStateException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() AMQ_CATCH_RETHROW(ActiveMQException) AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) AMQ_CATCHALL_THROW(ActiveMQException) @@ -2510,7 +2626,7 @@ void ActiveMQConnection::cleanUpTempDestinations() this->deleteTempDestination(dest); } } - catch (Exception& ex) + catch (const std::exception&) { } } diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h b/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h index eaadc253a..804d3729f 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h +++ b/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h @@ -31,15 +31,13 @@ #include #include #include -#include -#include -#include #include #include #include #include #include +#include #include namespace activemq @@ -230,11 +228,11 @@ namespace core * @param destination * The Destination the Broker will be requested to remove. * - * @throws NullPointerException + * @throws std::logic_error * If the passed Destination is Null - * @throws IllegalStateException + * @throws std::logic_error * If the connection is closed. - * @throws UnsupportedOperationException + * @throws std::logic_error * If the wire format in use does not support this operation. * @throws ActiveMQException * If any other error occurs during the attempt to destroy the @@ -253,11 +251,11 @@ namespace core * @param destination * The CMS Destination the Broker will be requested to remove. * - * @throws NullPointerException + * @throws std::logic_error * If the passed Destination is Null - * @throws IllegalStateException + * @throws std::logic_error * If the connection is closed. - * @throws UnsupportedOperationException + * @throws std::logic_error * If the wire format in use does not support this operation. * @throws ActiveMQException * If any other error occurs during the attempt to destroy the diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp index a011b59be..39c81fcf8 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp +++ b/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -48,7 +47,6 @@ using namespace decaf::net; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// const std::string ActiveMQConnectionFactory::DEFAULT_URI = @@ -494,15 +492,11 @@ cms::Connection* ActiveMQConnectionFactory::doCreateConnection( ex.setMark(__FILE__, __LINE__); throw ex.convertToCMSException(); } - catch (decaf::lang::Exception& ex) - { - ex.setMark(__FILE__, __LINE__); - activemq::exceptions::ActiveMQException amqEx(ex); - throw amqEx.convertToCMSException(); - } catch (std::exception& ex) { - throw cms::CMSException(ex.what(), nullptr); + ActiveMQException amqEx(__FILE__, __LINE__, "%s", ex.what()); + amqEx.setMark(__FILE__, __LINE__); + throw amqEx.convertToCMSException(); } catch (...) { diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp index 3c79b12bb..11fb30658 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp +++ b/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp @@ -31,7 +31,6 @@ using namespace activemq::core; using namespace activemq::core::kernels; using namespace activemq::exceptions; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQDestinationEvent.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQDestinationEvent.cpp index 140c73d9b..91bd18c1c 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQDestinationEvent.cpp +++ b/activemq-cpp/src/main/activemq/core/ActiveMQDestinationEvent.cpp @@ -19,8 +19,9 @@ #include #include - -#include +#include +#include +#include using namespace cms; using namespace activemq; @@ -28,7 +29,6 @@ using namespace activemq::core; using namespace activemq::commands; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// ActiveMQDestinationEvent::ActiveMQDestinationEvent( @@ -38,9 +38,10 @@ ActiveMQDestinationEvent::ActiveMQDestinationEvent( { if (destination == nullptr) { - throw NullPointerException(__FILE__, - __LINE__, - "Events cannot have null destinations"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Events cannot have null destinations"); } } diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQDestinationSource.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQDestinationSource.cpp index 0848b3788..4984b92fd 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQDestinationSource.cpp +++ b/activemq-cpp/src/main/activemq/core/ActiveMQDestinationSource.cpp @@ -23,11 +23,11 @@ #include #include -#include #include #include #include #include +#include #include #include @@ -37,7 +37,9 @@ #include #include #include +#include #include +#include using namespace cms; using namespace activemq; @@ -46,7 +48,6 @@ using namespace activemq::core; using namespace activemq::commands; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -170,20 +171,14 @@ namespace core { std::shared_ptr payload = amqMessage->getDataStructure(); - try - { - std::shared_ptr destinationInfo = - std::dynamic_pointer_cast(payload); - if (!destinationInfo) - { - return; - } - ActiveMQDestinationEvent event(destinationInfo); - handleDestinationEvent(event); - } - catch (ClassCastException& ex) + std::shared_ptr destinationInfo = + std::dynamic_pointer_cast(payload); + if (!destinationInfo) { + return; } + ActiveMQDestinationEvent event(destinationInfo); + handleDestinationEvent(event); } } @@ -352,9 +347,10 @@ ActiveMQDestinationSource::ActiveMQDestinationSource( { if (connection == nullptr) { - throw NullPointerException(__FILE__, - __LINE__, - "Connection passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Connection passed was NULL"); } this->impl->connection = connection; diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQMessageAudit.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQMessageAudit.cpp index 80156762f..d8f898a77 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQMessageAudit.cpp +++ b/activemq-cpp/src/main/activemq/core/ActiveMQMessageAudit.cpp @@ -36,7 +36,6 @@ using namespace activemq::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// AMQCPP_API const int ActiveMQMessageAudit::DEFAULT_WINDOW_SIZE = 2048; @@ -162,7 +161,7 @@ bool ActiveMQMessageAudit::isDuplicate(const std::string& id) const { bits = this->impl->map.get(seed); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { bits.reset(new BitSet(this->impl->auditDepth)); this->impl->map.put(seed, bits); @@ -208,7 +207,7 @@ bool ActiveMQMessageAudit::isDuplicate(std::shared_ptr msgId) const { bits = this->impl->map.get(seed); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { bits.reset(new BitSet(this->impl->auditDepth)); this->impl->map.put(seed, bits); @@ -249,7 +248,7 @@ void ActiveMQMessageAudit::rollback(const std::string& msgId) { bits = this->impl->map.get(seed); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { } @@ -289,7 +288,7 @@ void ActiveMQMessageAudit::rollback(std::shared_ptr msgId) { bits = this->impl->map.get(seed); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { } @@ -330,7 +329,7 @@ bool ActiveMQMessageAudit::isInOrder(const std::string& msgId) const { bits = this->impl->map.get(seed); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { bits.reset(new BitSet(this->impl->auditDepth)); this->impl->map.put(seed, bits); @@ -374,7 +373,7 @@ bool ActiveMQMessageAudit::isInOrder( { bits = this->impl->map.get(seed); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { bits.reset(new BitSet(this->impl->auditDepth)); this->impl->map.put(seed, bits); @@ -414,7 +413,7 @@ long long ActiveMQMessageAudit::getLastSeqId( { bits = this->impl->map.get(seed); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { } diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp index 1bdaf9423..c01795f24 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp +++ b/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp @@ -18,7 +18,6 @@ #include #include -#include using namespace std; using namespace activemq; @@ -27,7 +26,6 @@ using namespace activemq::core; using namespace activemq::core::kernels; using namespace activemq::exceptions; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// ActiveMQProducer::ActiveMQProducer( diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQQueueBrowser.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQQueueBrowser.cpp index 042174049..6fea82747 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQQueueBrowser.cpp +++ b/activemq-cpp/src/main/activemq/core/ActiveMQQueueBrowser.cpp @@ -29,6 +29,7 @@ #include #include +#include using namespace std; using namespace activemq; @@ -374,7 +375,7 @@ std::shared_ptr ActiveMQQueueBrowser::createConsumer() this->session->addConsumer(consumer); this->session->syncRequest(consumer->getConsumerInfo()); } - catch (Exception& ex) + catch (const std::exception&) { this->session->removeConsumer(consumer); throw; diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp index 8a81358e2..7b7af5e4c 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp +++ b/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp @@ -26,8 +26,6 @@ #include -#include - using namespace std; using namespace activemq; using namespace activemq::util; @@ -36,7 +34,6 @@ using namespace activemq::core::kernels; using namespace activemq::commands; using namespace activemq::exceptions; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// ActiveMQSession::ActiveMQSession(std::shared_ptr kernel) diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQSessionExecutor.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQSessionExecutor.cpp index 8a366e487..a4960c9de 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQSessionExecutor.cpp +++ b/activemq-cpp/src/main/activemq/core/ActiveMQSessionExecutor.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include using namespace std; @@ -32,7 +34,6 @@ using namespace activemq::core; using namespace activemq::core::kernels; using namespace activemq::threads; using namespace activemq::exceptions; -using namespace decaf::lang; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -193,7 +194,11 @@ void ActiveMQSessionExecutor::dispatch( consumer->dispatch(dispatch); } } - catch (decaf::lang::Exception& ex) + catch (activemq::exceptions::IOException& ex) + { + ex.setMark(__FILE__, __LINE__); + } + catch (activemq::exceptions::ActiveMQException& ex) { ex.setMark(__FILE__, __LINE__); } @@ -229,7 +234,14 @@ bool ActiveMQSessionExecutor::iterate() return false; } - catch (decaf::lang::Exception& ex) + catch (activemq::exceptions::IOException& ex) + { + ex.setMark(__FILE__, __LINE__); + ActiveMQException amq(ex); + session->fire(amq); + return true; + } + catch (activemq::exceptions::ActiveMQException& ex) { ex.setMark(__FILE__, __LINE__); session->fire(ex); diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.cpp index cf15e9546..9e5bdf635 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.cpp +++ b/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.cpp @@ -25,16 +25,19 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include -#include #include #include +#include +#include using namespace std; using namespace cms; @@ -46,7 +49,6 @@ using namespace activemq::exceptions; using namespace activemq::util; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -128,7 +130,7 @@ ActiveMQTransactionContext::ActiveMQTransactionContext( { if (session == nullptr) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ActiveMQTransactionContext::ActiveMQTransactionContext - " @@ -479,11 +481,11 @@ int ActiveMQTransactionContext::recover(int flag AMQCPP_UNUSED, Xid** recovered) return size; } - catch (Exception& e) + catch (CMSException& e) { throw toXAException(e); } - catch (CMSException& e) + catch (std::exception& e) { throw toXAException(e); } @@ -566,7 +568,7 @@ int ActiveMQTransactionContext::prepare(const Xid* xid) return intResponse->getResult(); } - catch (Exception& e) + catch (CMSException& e) { try { @@ -578,7 +580,7 @@ int ActiveMQTransactionContext::prepare(const Xid* xid) throw toXAException(e); } - catch (CMSException& e) + catch (std::exception& e) { try { @@ -631,7 +633,7 @@ void ActiveMQTransactionContext::commit(const Xid* xid, bool onePhase) this->afterCommit(); } - catch (Exception& ex) + catch (CMSException& e) { try { @@ -641,9 +643,9 @@ void ActiveMQTransactionContext::commit(const Xid* xid, bool onePhase) { } - throw toXAException(ex); + throw toXAException(e); } - catch (CMSException& e) + catch (std::exception& ex) { try { @@ -653,7 +655,7 @@ void ActiveMQTransactionContext::commit(const Xid* xid, bool onePhase) { } - throw toXAException(e); + throw toXAException(ex); } } @@ -699,14 +701,14 @@ void ActiveMQTransactionContext::rollback(const Xid* xid) this->afterRollback(); } - catch (Exception& ex) - { - throw toXAException(ex); - } catch (CMSException& e) { throw toXAException(e); } + catch (std::exception& ex) + { + throw toXAException(ex); + } } //////////////////////////////////////////////////////////////////////////////// @@ -729,11 +731,11 @@ void ActiveMQTransactionContext::end(const Xid* xid, int flags) { this->beforeEnd(); } - catch (Exception& e) + catch (CMSException& e) { throw toXAException(e); } - catch (CMSException& e) + catch (std::exception& e) { throw toXAException(e); } @@ -750,14 +752,14 @@ void ActiveMQTransactionContext::end(const Xid* xid, int flags) { beforeEnd(); } - catch (Exception& ex) - { - throw toXAException(ex); - } catch (CMSException& e) { throw toXAException(e); } + catch (std::exception& ex) + { + throw toXAException(ex); + } setXid(NULL); } @@ -805,14 +807,14 @@ void ActiveMQTransactionContext::forget(const Xid* xid) this->connection->syncRequest(info, this->connection->getRequestTimeout()); } - catch (Exception& ex) - { - throw toXAException(ex); - } catch (CMSException& e) { throw toXAException(e); } + catch (std::exception& ex) + { + throw toXAException(ex); + } } //////////////////////////////////////////////////////////////////////////////// @@ -835,14 +837,14 @@ bool ActiveMQTransactionContext::isSameRM(const XAResource* resource) { return getResourceManagerId() == cntx->getResourceManagerId(); } - catch (Exception& ex) - { - throw toXAException(ex); - } catch (CMSException& ex) { throw XAException("Could not get the Resource Manager Id.", ex.clone()); } + catch (std::exception& ex) + { + throw toXAException(ex); + } } //////////////////////////////////////////////////////////////////////////////// @@ -853,11 +855,11 @@ void ActiveMQTransactionContext::setXid(const Xid* xid) this->connection->checkClosedOrFailed(); this->connection->ensureConnectionInfoSent(); } - catch (Exception& e) + catch (CMSException& e) { throw toXAException(e); } - catch (CMSException& e) + catch (std::exception& e) { throw toXAException(e); } @@ -883,11 +885,11 @@ void ActiveMQTransactionContext::setXid(const Xid* xid) { this->connection->oneway(info); } - catch (Exception& e) + catch (CMSException& e) { throw toXAException(e); } - catch (CMSException& e) + catch (std::exception& e) { throw toXAException(e); } @@ -981,10 +983,19 @@ std::string ActiveMQTransactionContext::getResourceManagerId() const } //////////////////////////////////////////////////////////////////////////////// -XAException ActiveMQTransactionContext::toXAException(decaf::lang::Exception& ex) +XAException ActiveMQTransactionContext::toXAException(std::exception& ex) { - CMSException cmsEx = CMSExceptionSupport::create(ex); - XAException xae(ex.getMessage(), cmsEx.clone()); + const decaf::lang::Exception* dex = + dynamic_cast(&ex); + CMSException cmsEx = dex != nullptr ? CMSExceptionSupport::create(*dex) + : CMSExceptionSupport::create(ex); + std::string msg = dex != nullptr ? dex->getMessage() + : std::string(ex.what()); + if (msg.empty()) + { + msg = typeid(ex).name(); + } + XAException xae(msg, cmsEx.clone()); xae.setErrorCode(XAException::XAER_RMFAIL); return xae; } diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.h b/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.h index 3a9173b22..dea18c4ef 100644 --- a/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.h +++ b/activemq-cpp/src/main/activemq/core/ActiveMQTransactionContext.h @@ -17,6 +17,7 @@ #ifndef _ACTIVEMQ_CORE_ACTIVEMQTRANSACTIONCONTEXT_H_ #define _ACTIVEMQ_CORE_ACTIVEMQTRANSACTIONCONTEXT_H_ +#include #include #include @@ -30,7 +31,6 @@ #include #include -#include #include #include #include @@ -127,7 +127,7 @@ namespace core * Get the Transaction Id object for the current * Transaction, returns NULL if no transaction is running * @return TransactionInfo - * @throw InvalidStateException if a Transaction is not in progress. + * @throw std::logic_error if a Transaction is not in progress. */ virtual const std::shared_ptr& getTransactionId() const; @@ -182,7 +182,7 @@ namespace core void setXid(const cms::Xid* xid); bool equals(const cms::Xid* local, const cms::Xid* remote); cms::XAException toXAException(cms::CMSException& ex); - cms::XAException toXAException(decaf::lang::Exception& ex); + cms::XAException toXAException(std::exception& ex); void beforeEnd(); void afterCommit(); diff --git a/activemq-cpp/src/main/activemq/core/AdvisoryConsumer.cpp b/activemq-cpp/src/main/activemq/core/AdvisoryConsumer.cpp index 9c7fc2556..a3ff595e7 100644 --- a/activemq-cpp/src/main/activemq/core/AdvisoryConsumer.cpp +++ b/activemq-cpp/src/main/activemq/core/AdvisoryConsumer.cpp @@ -18,9 +18,11 @@ #include "AdvisoryConsumer.h" #include +#include #include -#include #include +#include +#include using namespace activemq; using namespace activemq::core; @@ -30,7 +32,6 @@ using namespace activemq::exceptions; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -70,9 +71,10 @@ AdvisoryConsumer::AdvisoryConsumer( { if (connection == nullptr) { - throw NullPointerException(__FILE__, - __LINE__, - "Parent Connection pointer was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Parent Connection pointer was NULL"); } this->config->info.reset(new ConsumerInfo()); @@ -160,17 +162,11 @@ void AdvisoryConsumer::dispatch(const std::shared_ptr& message) message->getMessage()->getDataStructure(); if (object != nullptr) { - try - { - std::shared_ptr info = - std::dynamic_pointer_cast(object); - if (info != nullptr) - { - processDestinationInfo(info); - } - } - catch (ClassCastException& ex) + std::shared_ptr info = + std::dynamic_pointer_cast(object); + if (info != nullptr) { + processDestinationInfo(info); } } } diff --git a/activemq-cpp/src/main/activemq/core/ConnectionAudit.cpp b/activemq-cpp/src/main/activemq/core/ConnectionAudit.cpp index ec9b7fc3c..a1a686c14 100644 --- a/activemq-cpp/src/main/activemq/core/ConnectionAudit.cpp +++ b/activemq-cpp/src/main/activemq/core/ConnectionAudit.cpp @@ -32,7 +32,6 @@ using namespace activemq::exceptions; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -105,7 +104,7 @@ void ConnectionAudit::removeDispatcher(Dispatcher* dispatcher) { this->impl->dispatchers.remove(dispatcher); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { } } @@ -130,7 +129,7 @@ bool ConnectionAudit::isDuplicate(Dispatcher* dispatcher, { audit = this->impl->destinations.get(destination); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { audit.reset(new ActiveMQMessageAudit( auditDepth, @@ -145,7 +144,7 @@ bool ConnectionAudit::isDuplicate(Dispatcher* dispatcher, { audit = this->impl->dispatchers.get(dispatcher); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { audit.reset( new ActiveMQMessageAudit(auditDepth, @@ -181,7 +180,7 @@ void ConnectionAudit::rollbackDuplicate( this->impl->destinations.get(destination); audit->rollback(message->getMessageId()); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { } } @@ -193,7 +192,7 @@ void ConnectionAudit::rollbackDuplicate( this->impl->dispatchers.get(dispatcher); audit->rollback(message->getMessageId()); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { } } diff --git a/activemq-cpp/src/main/activemq/core/FifoMessageDispatchChannel.cpp b/activemq-cpp/src/main/activemq/core/FifoMessageDispatchChannel.cpp index de1daa4d5..3a7292fec 100644 --- a/activemq-cpp/src/main/activemq/core/FifoMessageDispatchChannel.cpp +++ b/activemq-cpp/src/main/activemq/core/FifoMessageDispatchChannel.cpp @@ -98,7 +98,7 @@ std::shared_ptr FifoMessageDispatchChannel::dequeue( return std::shared_ptr(); } - // Use pollFirst instead of pop to avoid NoSuchElementException + // Use pollFirst instead of pop to avoid std::runtime_error std::shared_ptr result; if (channel.pollFirst(result)) { @@ -119,7 +119,7 @@ std::shared_ptr FifoMessageDispatchChannel::dequeueNoWait() return std::shared_ptr(); } - // Use pollFirst instead of pop to avoid NoSuchElementException + // Use pollFirst instead of pop to avoid std::runtime_error std::shared_ptr result; if (channel.pollFirst(result)) { @@ -140,7 +140,7 @@ std::shared_ptr FifoMessageDispatchChannel::peek() const return std::shared_ptr(); } - // Use peekFirst instead of getFirst to avoid NoSuchElementException + // Use peekFirst instead of getFirst to avoid std::runtime_error std::shared_ptr result; if (channel.peekFirst(result)) { diff --git a/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h b/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h index 546cf33d7..11d1290af 100644 --- a/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h +++ b/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h @@ -21,6 +21,7 @@ #include #include +#include namespace activemq { @@ -147,9 +148,9 @@ namespace core * @param properties * The Properties object used to configure this object. * - * @throws NumberFormatException if a property that is numeric cannot be + * @throws std::invalid_argument if a property that is numeric cannot be * converted - * @throws IllegalArgumentException if a property can't be converted to + * @throws std::invalid_argument if a property can't be converted to * the correct type. */ virtual void configure(const decaf::util::Properties& properties); diff --git a/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h b/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h index 59aa769b7..4d237c236 100644 --- a/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h +++ b/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h @@ -21,6 +21,7 @@ #include #include +#include namespace activemq { @@ -193,9 +194,9 @@ namespace core * @param properties * The Properties object used to configure this object. * - * @throws NumberFormatException if a property that is numeric cannot be + * @throws std::invalid_argument if a property that is numeric cannot be * converted - * @throws IllegalArgumentException if a property can't be converted to + * @throws std::invalid_argument if a property can't be converted to * the correct type. */ virtual void configure(const decaf::util::Properties& properties); diff --git a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.cpp b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.cpp index 0ac158d42..b87a3a387 100644 --- a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.cpp +++ b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.cpp @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include #include @@ -40,19 +42,20 @@ #include #include #include +#include #include +#include #include -#include -#include -#include #include #include #include #include #include #include +#include #include #include +#include using namespace std; using namespace activemq; @@ -63,7 +66,6 @@ using namespace activemq::commands; using namespace activemq::exceptions; using namespace activemq::threads; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -413,7 +415,7 @@ namespace core 500LL, failoverRedeliveryWaitPeriod / 4)); } - catch (InterruptedException& ex) + catch (activemq::exceptions::InterruptedException&) { break; } @@ -555,11 +557,16 @@ namespace core << ", exceeded=" << exceeded); return exceeded; } - catch (Exception& ignored) + catch (const std::exception& ignored) { // Property access failed (likely corrupted) - redelivery IS // exceeded Send POISON_ACK immediately for corrupted // messages + const decaf::lang::Exception* dex = + dynamic_cast(&ignored); + std::string msg = dex != nullptr + ? dex->getMessage() + : std::string(ignored.what()); AMQ_LOG_ERROR( "ActiveMQConsumerKernel", "redeliveryExceeded(): Property access failed for " @@ -567,7 +574,7 @@ namespace core << dispatch->getMessage()->getMessageId()->toString() << ", redeliveryCount=" << dispatch->getRedeliveryCounter() - << ", exception=" << ignored.getMessage() + << ", exception=" << msg << " - treating as exceeded, will send POISON_ACK"); return true; } @@ -644,9 +651,7 @@ class TransactionSynhcronization : public Synchronization { if (consumer == nullptr) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Synchronization Created with NULL Consumer."); } } @@ -708,9 +713,7 @@ class CloseSynhcronization : public Synchronization { if (consumer == nullptr) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Synchronization Created with NULL Consumer."); } } @@ -773,7 +776,7 @@ class ClientAckHandler : public ActiveMQAckHandler { if (session == nullptr) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Ack Handler Created with NULL Session."); @@ -811,7 +814,7 @@ class IndividualAckHandler : public ActiveMQAckHandler { if (consumer == nullptr) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Ack Handler Created with NULL consumer."); @@ -855,9 +858,7 @@ class StartConsumerTask : public Runnable { if (consumer == nullptr) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Synchronization Created with NULL Consumer."); } } @@ -918,11 +919,7 @@ class AsyncMessageAckTask : public Runnable this->session->sendAck(ack, true); this->impl->deliveringAcks.store(false); } - catch (Exception& ex) - { - this->impl->deliveringAcks.store(false); - } - catch (cms::CMSException& ex) + catch (const std::exception&) { this->impl->deliveringAcks.store(false); } @@ -967,9 +964,14 @@ class OptimizedAckTask : public Runnable this->consumer->deliverAcks(); } } - catch (Exception& ex) + catch (const std::exception& ex) { - impl->session->getConnection()->onAsyncException(ex); + const decaf::lang::Exception* dex = + dynamic_cast(&ex); + if (dex != nullptr) + { + impl->session->getConnection()->onAsyncException(*dex); + } } } }; @@ -1024,9 +1026,14 @@ class NonBlockingRedeliveryTask : public Runnable } } } - catch (Exception& e) + catch (const std::exception& e) { - session->getConnection()->onAsyncException(e); + const decaf::lang::Exception* dex = + dynamic_cast(&e); + if (dex != nullptr) + { + session->getConnection()->onAsyncException(*dex); + } } this->consumer.reset(); @@ -1053,9 +1060,9 @@ ActiveMQConsumerKernel::ActiveMQConsumerKernel( { if (session == nullptr) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Consumer created with NULL Session"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Consumer created with NULL Session"); } if (destination == nullptr) @@ -1173,9 +1180,8 @@ ActiveMQConsumerKernel::ActiveMQConsumerKernel( if (this->consumerInfo->getPrefetchSize() < 0) { delete this->internal; - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Cannot create a consumer with a negative prefetch"); } @@ -1275,8 +1281,8 @@ void ActiveMQConsumerKernel::doClose() try { // Store interrupted state and clear so that Transport operations don't - // throw InterruptedException and we ensure that resources are clened - // up. + // throw activemq::exceptions::InterruptedException and we ensure + // that resources are clened up. bool interrupted = Thread::interrupted(); dispose(); @@ -1408,7 +1414,7 @@ void ActiveMQConsumerKernel::dispose() { this->session->removeConsumer(consumer); } - catch (Exception& e) + catch (const std::exception&) { throw; } @@ -1551,7 +1557,7 @@ std::shared_ptr ActiveMQConsumerKernel::dequeue( return std::shared_ptr(); } - catch (InterruptedException& ex) + catch (activemq::exceptions::InterruptedException& ex) { Thread::currentThread()->interrupt(); throw CMSExceptionSupport::create(ex); @@ -1886,9 +1892,10 @@ void ActiveMQConsumerKernel::afterMessageIsConsumed( } else { - throw IllegalStateException(__FILE__, - __LINE__, - "Invalid Session State"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Invalid Session State"); } } AMQ_CATCH_RETHROW(ActiveMQException) @@ -2337,11 +2344,13 @@ void ActiveMQConsumerKernel::dispatch( { if (dispatch == nullptr) { - throw std::invalid_argument("dispatch was NULL"); + throw activemq::exceptions::InvalidArgumentException( + "dispatch was NULL"); } if (dispatch->getMessage() == nullptr) { - throw std::invalid_argument("dispatch message was NULL"); + throw activemq::exceptions::InvalidArgumentException( + "dispatch message was NULL"); } try @@ -2448,7 +2457,7 @@ void ActiveMQConsumerKernel::dispatch( } afterMessageIsConsumed(dispatch, expired); } - catch (decaf::io::IOException& e) + catch (activemq::exceptions::IOException& e) { // Lazy property unmarshaling failed (corrupted // properties) - C# client behavior Property @@ -2466,7 +2475,13 @@ void ActiveMQConsumerKernel::dispatch( << ", exception=" << e.getMessage() << ", redeliveryCount=" << dispatch->getRedeliveryCounter()); - dispatch->setRollbackCause(e); + ActiveMQException rollbackCause( + __FILE__, + __LINE__, + "%s", + e.getMessage().c_str()); + rollbackCause.setMark(__FILE__, __LINE__); + dispatch->setRollbackCause(rollbackCause); if (isAutoAcknowledgeBatch() || isAutoAcknowledgeEach() || session->isIndividualAcknowledge()) @@ -2482,7 +2497,33 @@ void ActiveMQConsumerKernel::dispatch( afterMessageIsConsumed(dispatch, false); } } - catch (RuntimeException& e) + catch (decaf::io::IOException& e) + { + AMQ_LOG_ERROR( + "ActiveMQConsumerKernel", + "dispatch(): Property unmarshal failed " + "(corrupted) for message id=" + << dispatch->getMessage() + ->getMessageId() + ->toString() + << ", exception=" << e.getMessage() + << ", redeliveryCount=" + << dispatch->getRedeliveryCounter()); + ActiveMQException rollbackCause(e); + rollbackCause.setMark(__FILE__, __LINE__); + dispatch->setRollbackCause(rollbackCause); + if (isAutoAcknowledgeBatch() || + isAutoAcknowledgeEach() || + session->isIndividualAcknowledge()) + { + rollback(); + } + else + { + afterMessageIsConsumed(dispatch, false); + } + } + catch (activemq::exceptions::ActiveMQException& e) { AMQ_LOG_ERROR("ActiveMQConsumerKernel", "dispatch(): Exception in " @@ -2508,6 +2549,32 @@ void ActiveMQConsumerKernel::dispatch( afterMessageIsConsumed(dispatch, false); } } + catch (std::exception& e) + { + decaf::lang::Exception dex(__FILE__, + __LINE__, + "%s", + e.what()); + AMQ_LOG_ERROR("ActiveMQConsumerKernel", + "dispatch(): Exception in " + "message listener for message id=" + << dispatch->getMessage() + ->getMessageId() + ->toString() + << ", exception=" + << e.what()); + dispatch->setRollbackCause(dex); + if (isAutoAcknowledgeBatch() || + isAutoAcknowledgeEach() || + session->isIndividualAcknowledge()) + { + rollback(); + } + else + { + afterMessageIsConsumed(dispatch, false); + } + } } else { @@ -2607,9 +2674,7 @@ std::unique_ptr ActiveMQConsumerKernel::createCMSMessage( { if (transformed == nullptr) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Client MessageTransformer returned a NULL message"); } @@ -2707,7 +2772,8 @@ void ActiveMQConsumerKernel::checkClosed() const { if (this->isClosed()) { - throw cms::IllegalStateException("Consumer Already Closed"); + throw activemq::exceptions::IllegalStateException( + "Consumer Already Closed"); } } @@ -2716,7 +2782,7 @@ void ActiveMQConsumerKernel::checkMessageListener() const { if (this->internal->listener != nullptr) { - throw cms::IllegalStateException( + throw activemq::exceptions::IllegalStateException( "Cannot synchronously receive a message when a MessageListener is " "set"); } @@ -3071,7 +3137,7 @@ void ActiveMQConsumerKernel::setOptimizedAckScheduledAckInterval(long long value this->internal->optimizedAckTask); this->internal->optimizedAckTask = nullptr; } - catch (Exception& e) + catch (const std::exception& e) { this->internal->optimizedAckTask = nullptr; throw CMSExceptionSupport::create(e); @@ -3094,7 +3160,7 @@ void ActiveMQConsumerKernel::setOptimizedAckScheduledAckInterval(long long value this->internal->optimizedAckTask, this->internal->optimizedAckScheduledAckInterval); } - catch (Exception& e) + catch (const std::exception& e) { throw CMSExceptionSupport::create(e); } diff --git a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.h b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.h index 92f905781..a4a96e3e1 100644 --- a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.h +++ b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.h @@ -432,7 +432,7 @@ namespace core * @return the message, if received within the allotted time. * Otherwise NULL. * - * @throws InvalidStateException if this consumer is closed upon + * @throws std::logic_error if this consumer is closed upon * entering this method. */ std::shared_ptr dequeue(long long timeout); diff --git a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQProducerKernel.cpp b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQProducerKernel.cpp index c75592d8b..71a604761 100644 --- a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQProducerKernel.cpp +++ b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQProducerKernel.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -27,9 +28,7 @@ #include #include #include -#include -#include -#include +#include using namespace std; using namespace activemq; @@ -40,7 +39,6 @@ using namespace activemq::commands; using namespace activemq::exceptions; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// ActiveMQProducerKernel::ActiveMQProducerKernel( @@ -377,7 +375,7 @@ void ActiveMQProducerKernel::send(const cms::Destination* destination, } if (outbound == nullptr) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "MessageTransformer set transformed message to NULL"); @@ -390,7 +388,7 @@ void ActiveMQProducerKernel::send(const cms::Destination* destination, { this->memoryUsage->waitForSpace(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException&) { AMQ_LOG_ERROR("ActiveMQProducerKernel", "send(): Thread interrupted while waiting for " diff --git a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp index 687dbc18b..a987f929f 100644 --- a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp +++ b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp @@ -49,17 +49,19 @@ #include #include +#include #include #include #include -#include -#include #include #include #include #include #include #include +#include +#include +#include using namespace std; using namespace activemq; @@ -72,7 +74,6 @@ using namespace activemq::threads; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace activemq @@ -146,9 +147,7 @@ namespace core { if (consumer == nullptr) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Synchronization Created with NULL Consumer."); } } @@ -188,9 +187,7 @@ namespace core { if (session == nullptr || config == nullptr) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Synchronization Created with NULL Session."); } } @@ -467,7 +464,7 @@ void ActiveMQSessionKernel::dispose() this->config->consumers.clear(); this->config->consumerLock.writeLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.writeLock().unlock(); throw; @@ -499,7 +496,7 @@ void ActiveMQSessionKernel::dispose() this->config->producers.clear(); this->config->producerLock.writeLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->producerLock.writeLock().unlock(); throw; @@ -584,7 +581,8 @@ void ActiveMQSessionKernel::recover() if (isTransacted()) { - throw cms::IllegalStateException("This session is transacted"); + throw activemq::exceptions::IllegalStateException( + "This session is transacted"); } AMQ_LOG_INFO("SessionKernel", @@ -603,7 +601,7 @@ void ActiveMQSessionKernel::recover() } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -637,7 +635,7 @@ void ActiveMQSessionKernel::clearMessagesInProgress( } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -659,7 +657,7 @@ void ActiveMQSessionKernel::acknowledge() } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -681,7 +679,7 @@ void ActiveMQSessionKernel::deliverAcks() } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -778,7 +776,7 @@ cms::MessageConsumer* ActiveMQSessionKernel::createConsumer( "SessionKernel", "createConsumer() syncRequest completed successfully"); } - catch (Exception& ex) + catch (const std::exception&) { this->removeConsumer(consumer); throw; @@ -851,7 +849,7 @@ cms::MessageConsumer* ActiveMQSessionKernel::createDurableConsumer( "SessionKernel", "createDurableConsumer() syncRequest completed successfully"); } - catch (Exception& ex) + catch (const std::exception&) { this->removeConsumer(consumer); throw; @@ -919,7 +917,7 @@ cms::MessageProducer* ActiveMQSessionKernel::createProducer( "SessionKernel", "createProducer() syncRequest completed successfully"); } - catch (Exception& ex) + catch (const std::exception&) { this->removeProducer(producer); throw; @@ -989,9 +987,8 @@ cms::Queue* ActiveMQSessionKernel::createQueue(const std::string& queueName) if (queueName == "") { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Destination Name cannot be the Empty String."); } @@ -1016,9 +1013,8 @@ cms::Topic* ActiveMQSessionKernel::createTopic(const std::string& topicName) if (topicName == "") { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Destination Name cannot be the Empty String."); } @@ -1435,7 +1431,7 @@ void ActiveMQSessionKernel::start() } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -1463,7 +1459,7 @@ void ActiveMQSessionKernel::stop() } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -1534,7 +1530,7 @@ bool ActiveMQSessionKernel::isInUse( } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -1632,7 +1628,7 @@ void ActiveMQSessionKernel::addConsumer( this->config->consumers.add(consumer); this->config->consumerLock.writeLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.writeLock().unlock(); throw; @@ -1674,7 +1670,7 @@ void ActiveMQSessionKernel::removeConsumer( } this->config->consumerLock.writeLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.writeLock().unlock(); throw; @@ -1699,7 +1695,7 @@ void ActiveMQSessionKernel::addProducer( this->config->producers.add(producer); this->config->producerLock.writeLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->producerLock.writeLock().unlock(); throw; @@ -1725,7 +1721,7 @@ void ActiveMQSessionKernel::removeProducer( this->config->producers.remove(producer); this->config->producerLock.writeLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->producerLock.writeLock().unlock(); throw; @@ -1759,7 +1755,7 @@ ActiveMQSessionKernel::lookupProducerKernel(std::shared_ptr id) this->config->producerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->producerLock.readLock().unlock(); throw; @@ -1789,7 +1785,7 @@ ActiveMQSessionKernel::lookupConsumerKernel(std::shared_ptr id) } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -1823,7 +1819,7 @@ bool ActiveMQSessionKernel::iterateConsumers() } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -1852,7 +1848,7 @@ void ActiveMQSessionKernel::setPrefetchSize(std::shared_ptr id, } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -1884,7 +1880,7 @@ void ActiveMQSessionKernel::close(std::shared_ptr id) } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -1952,14 +1948,14 @@ void ActiveMQSessionKernel::checkMessageListener() const std::shared_ptr consumer = iter->next(); if (consumer->getMessageListener() != nullptr) { - throw cms::IllegalStateException( + throw activemq::exceptions::IllegalStateException( "Cannot synchronously receive a message when a " "MessageListener is set"); } } this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; @@ -2002,7 +1998,7 @@ ActiveMQSessionKernel::getConsumers() const result.addAll(this->config->consumers); this->config->consumerLock.readLock().unlock(); } - catch (Exception& ex) + catch (const std::exception&) { this->config->consumerLock.readLock().unlock(); throw; diff --git a/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.cpp b/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.cpp index 0d5e2fff0..c521d8e97 100644 --- a/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.cpp +++ b/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.cpp @@ -16,6 +16,8 @@ */ #include "ActiveMQException.h" + +#include #include #include @@ -47,6 +49,12 @@ ActiveMQException::ActiveMQException(const Exception& ex) { } +//////////////////////////////////////////////////////////////////////////////// +ActiveMQException::ActiveMQException(const activemq::exceptions::IOException& ex) + : decaf::lang::Exception(__FILE__, __LINE__, "%s", ex.getMessage().c_str()) +{ +} + //////////////////////////////////////////////////////////////////////////////// ActiveMQException::ActiveMQException(const char* file, const int lineNumber, diff --git a/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.h b/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.h index 2b60f2791..034c0ba11 100644 --- a/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.h +++ b/activemq-cpp/src/main/activemq/exceptions/ActiveMQException.h @@ -22,6 +22,7 @@ #endif #include +#include #include #include #include @@ -58,6 +59,11 @@ namespace exceptions */ ActiveMQException(const decaf::lang::Exception& ex); + /** + * Wrap AMQ STL-backed stream errors as a decaf Exception-derived type. + */ + ActiveMQException(const IOException& ex); + /** * Constructor - Initializes the file name and line number where * this message occurred. Sets the message to report, using an diff --git a/activemq-cpp/src/main/decaf/nio/BufferUnderflowException.cpp b/activemq-cpp/src/main/activemq/exceptions/BufferUnderflowException.cpp similarity index 55% rename from activemq-cpp/src/main/decaf/nio/BufferUnderflowException.cpp rename to activemq-cpp/src/main/activemq/exceptions/BufferUnderflowException.cpp index bbd5fbf34..4a16ae6fd 100644 --- a/activemq-cpp/src/main/decaf/nio/BufferUnderflowException.cpp +++ b/activemq-cpp/src/main/activemq/exceptions/BufferUnderflowException.cpp @@ -15,15 +15,16 @@ * limitations under the License. */ -#include "BufferUnderflowException.h" +#include -using namespace decaf; -using namespace decaf::nio; -using namespace decaf::lang; +#include +#include + +using namespace activemq::exceptions; //////////////////////////////////////////////////////////////////////////////// BufferUnderflowException::BufferUnderflowException() - : lang::Exception() + : std::out_of_range("") { } @@ -33,53 +34,68 @@ BufferUnderflowException::~BufferUnderflowException() throw() } //////////////////////////////////////////////////////////////////////////////// -BufferUnderflowException::BufferUnderflowException(const lang::Exception& ex) - : lang::Exception() +BufferUnderflowException::BufferUnderflowException( + const BufferUnderflowException& ex) + : std::out_of_range(ex) { - *(lang::Exception*)this = ex; } //////////////////////////////////////////////////////////////////////////////// -BufferUnderflowException::BufferUnderflowException( +BufferUnderflowException& BufferUnderflowException::operator=( const BufferUnderflowException& ex) - : lang::Exception() { - *(lang::Exception*)this = ex; + std::out_of_range::operator=(ex); + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +BufferUnderflowException::BufferUnderflowException(const std::string& message) + : std::out_of_range(message) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +BufferUnderflowException::BufferUnderflowException(const std::exception& ex) + : std::out_of_range(std::string(ex.what())) +{ } //////////////////////////////////////////////////////////////////////////////// BufferUnderflowException::BufferUnderflowException(const char* file, const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : lang::Exception(cause) + const char* plainMessage) + : std::out_of_range(buildSourceMessage(file, lineNumber, plainMessage)) { - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); +} - // Set the first mark for this exception. - setMark(file, lineNumber); +//////////////////////////////////////////////////////////////////////////////// +std::string BufferUnderflowException::messageFromOwnedCause( + const std::exception* cause) +{ + if (cause == NULL) + { + return ""; + } + std::string msg; + try + { + msg = std::string(cause->what()); + } + catch (...) + { + msg = ""; + } + delete cause; + return msg; } //////////////////////////////////////////////////////////////////////////////// BufferUnderflowException::BufferUnderflowException(const std::exception* cause) - : lang::Exception(cause) + : std::out_of_range(messageFromOwnedCause(cause)) { } //////////////////////////////////////////////////////////////////////////////// -BufferUnderflowException::BufferUnderflowException(const char* file, - const int lineNumber, - const char* msg, - ...) - : lang::Exception() +void BufferUnderflowException::setMark(const char*, int) noexcept { - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); } diff --git a/activemq-cpp/src/main/activemq/exceptions/BufferUnderflowException.h b/activemq-cpp/src/main/activemq/exceptions/BufferUnderflowException.h new file mode 100644 index 000000000..29f970ccb --- /dev/null +++ b/activemq-cpp/src/main/activemq/exceptions/BufferUnderflowException.h @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _ACTIVEMQ_EXCEPTIONS_BUFFERUNDERFLOWEXCEPTION_H_ +#define _ACTIVEMQ_EXCEPTIONS_BUFFERUNDERFLOWEXCEPTION_H_ + +#include +#include +#include +#include + +namespace activemq +{ +namespace exceptions +{ + + /** + * Thrown when a relative read reaches or exceeds the buffer limit. + * Derived from std::out_of_range so callers may catch either type. + */ + class AMQCPP_API BufferUnderflowException : public std::out_of_range + { + public: + BufferUnderflowException(); + + BufferUnderflowException(const BufferUnderflowException& ex); + + BufferUnderflowException& operator=(const BufferUnderflowException& ex); + + explicit BufferUnderflowException(const std::string& message); + + explicit BufferUnderflowException(const std::exception& ex); + + /** + * Builds message as file:line: plainMessage (via buildSourceMessage). + */ + BufferUnderflowException(const char* file, + const int lineNumber, + const char* plainMessage); + + /** + * Takes ownership of \p cause (typically from Exception::clone()) and + * builds the message from it. + */ + BufferUnderflowException(const std::exception* cause); + + virtual ~BufferUnderflowException() throw(); + + /** + * Compatibility with DECAF_CATCH_RETHROW; STL-backed exceptions have no + * stack trace — this is a no-op. + */ + void setMark(const char* file, int lineNumber) noexcept; + + private: + static std::string messageFromOwnedCause(const std::exception* cause); + }; + +} // namespace exceptions +} // namespace activemq + +#endif /* _ACTIVEMQ_EXCEPTIONS_BUFFERUNDERFLOWEXCEPTION_H_ */ diff --git a/activemq-cpp/src/main/activemq/exceptions/ExceptionTypes.h b/activemq-cpp/src/main/activemq/exceptions/ExceptionTypes.h new file mode 100644 index 000000000..c0a0306eb --- /dev/null +++ b/activemq-cpp/src/main/activemq/exceptions/ExceptionTypes.h @@ -0,0 +1,401 @@ +#ifndef _ACTIVEMQ_EXCEPTIONS_EXCEPTIONTYPES_H_ +#define _ACTIVEMQ_EXCEPTIONS_EXCEPTIONTYPES_H_ + +#include + +#include +#include +#include + +namespace activemq +{ +namespace exceptions +{ + + inline std::string buildSourceMessage(const char* file, + int lineNumber, + const char* message) + { + return std::string(file) + ":" + std::to_string(lineNumber) + ": " + + std::string(message); + } + + inline std::string buildSourceMessage(const char* file, + int lineNumber, + const std::string& message) + { + return std::string(file) + ":" + std::to_string(lineNumber) + ": " + + message; + } + + class AMQCPP_API InterruptedException : public std::runtime_error + { + public: + explicit InterruptedException(const std::string& message) + : std::runtime_error(message) + { + } + + InterruptedException(const char* file, + int lineNumber, + const char* message) + : std::runtime_error(buildSourceMessage(file, lineNumber, message)) + { + } + + InterruptedException(const char* file, + int lineNumber, + const std::string& message) + : std::runtime_error(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + /** + * General unchecked failure (Java RuntimeException analogue). + */ + class AMQCPP_API RuntimeException : public std::runtime_error + { + public: + RuntimeException() + : std::runtime_error("RuntimeException") + { + } + + explicit RuntimeException(const std::string& message) + : std::runtime_error(message) + { + } + + RuntimeException(const char* file, int lineNumber, const char* message) + : std::runtime_error(buildSourceMessage(file, lineNumber, message)) + { + } + + RuntimeException(const char* file, + int lineNumber, + const std::string& message) + : std::runtime_error(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + class AMQCPP_API IllegalStateException : public std::logic_error + { + public: + explicit IllegalStateException(const std::string& message) + : std::logic_error(message) + { + } + + IllegalStateException(const char* file, + int lineNumber, + const char* message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + + IllegalStateException(const char* file, + int lineNumber, + const std::string& message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + class AMQCPP_API InvalidStateException : public std::logic_error + { + public: + explicit InvalidStateException(const std::string& message) + : std::logic_error(message) + { + } + + InvalidStateException(const char* file, + int lineNumber, + const char* message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + + InvalidStateException(const char* file, + int lineNumber, + const std::string& message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + /** + * Object does not support cloning (Java CloneNotSupportedException + * analogue). + */ + class AMQCPP_API CloneNotSupportedException : public std::logic_error + { + public: + explicit CloneNotSupportedException(const std::string& message) + : std::logic_error(message) + { + } + + CloneNotSupportedException(const char* file, + int lineNumber, + const char* message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + + CloneNotSupportedException(const char* file, + int lineNumber, + const std::string& message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + class AMQCPP_API NullPointerException : public std::logic_error + { + public: + explicit NullPointerException(const std::string& message) + : std::logic_error(message) + { + } + + NullPointerException(const char* file, + int lineNumber, + const char* message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + + NullPointerException(const char* file, + int lineNumber, + const std::string& message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + class AMQCPP_API UnsupportedOperationException : public std::logic_error + { + public: + UnsupportedOperationException() + : std::logic_error("UnsupportedOperationException") + { + } + + explicit UnsupportedOperationException(const std::string& message) + : std::logic_error(message) + { + } + + UnsupportedOperationException(const char* file, + int lineNumber, + const char* message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + + UnsupportedOperationException(const char* file, + int lineNumber, + const std::string& message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + class AMQCPP_API IllegalMonitorStateException : public std::logic_error + { + public: + IllegalMonitorStateException() + : std::logic_error("IllegalMonitorStateException") + { + } + + explicit IllegalMonitorStateException(const std::string& message) + : std::logic_error(message) + { + } + + IllegalMonitorStateException(const char* file, + int lineNumber, + const char* message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + + IllegalMonitorStateException(const char* file, + int lineNumber, + const std::string& message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + /** + * Thrown when a value does not match an expected static type (for example + * OpenWire copyDataStructure / dynamic_cast failures). + */ + class AMQCPP_API TypeMismatchException : public std::logic_error + { + public: + explicit TypeMismatchException(const std::string& message) + : std::logic_error(message) + { + } + + TypeMismatchException(const char* file, + int lineNumber, + const char* message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + + TypeMismatchException(const char* file, + int lineNumber, + const std::string& message) + : std::logic_error(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + /** + * Index or range violation; derives from std::out_of_range so existing + * handlers can remain unchanged. + */ + class AMQCPP_API OutOfRangeException : public std::out_of_range + { + public: + explicit OutOfRangeException(const std::string& message) + : std::out_of_range(message) + { + } + + OutOfRangeException(const char* file, + int lineNumber, + const char* message) + : std::out_of_range(buildSourceMessage(file, lineNumber, message)) + { + } + + OutOfRangeException(const char* file, + int lineNumber, + const std::string& message) + : std::out_of_range(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + /** + * Structural modification during iteration or similar detected failures. + */ + class AMQCPP_API ConcurrentModificationException : public std::runtime_error + { + public: + explicit ConcurrentModificationException(const std::string& message) + : std::runtime_error(message) + { + } + + ConcurrentModificationException(const char* file, + int lineNumber, + const char* message) + : std::runtime_error(buildSourceMessage(file, lineNumber, message)) + { + } + + ConcurrentModificationException(const char* file, + int lineNumber, + const std::string& message) + : std::runtime_error(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + /** + * Iterator-style exhaustion (for example StringTokenizer::nextToken). + */ + class AMQCPP_API NoSuchElementException : public std::runtime_error + { + public: + NoSuchElementException() + : std::runtime_error("NoSuchElementException") + { + } + + explicit NoSuchElementException(const std::string& message) + : std::runtime_error(message) + { + } + + NoSuchElementException(const char* file, + int lineNumber, + const char* message) + : std::runtime_error(buildSourceMessage(file, lineNumber, message)) + { + } + + NoSuchElementException(const char* file, + int lineNumber, + const std::string& message) + : std::runtime_error(buildSourceMessage(file, lineNumber, message)) + { + } + }; + + /** + * Allocation failure; derives from std::bad_alloc so existing handlers and + * tests catching std::bad_alloc remain valid. Keeps static footprint + * minimal (no extra allocations for message storage). + */ + class AMQCPP_API OutOfMemoryError : public std::bad_alloc + { + public: + OutOfMemoryError() noexcept = default; + }; + + /** + * Invalid parameter or conversion input; derives from + * std::invalid_argument. + */ + class AMQCPP_API InvalidArgumentException : public std::invalid_argument + { + public: + explicit InvalidArgumentException(const std::string& message) + : std::invalid_argument(message) + { + } + + InvalidArgumentException(const char* file, + int lineNumber, + const char* message) + : std::invalid_argument( + buildSourceMessage(file, lineNumber, message)) + { + } + + InvalidArgumentException(const char* file, + int lineNumber, + const std::string& message) + : std::invalid_argument( + buildSourceMessage(file, lineNumber, message)) + { + } + }; + + /** + * Legacy Decaf / Java-style names for index and argument failures. + * These are type aliases to the thin STL-backed exceptions above so + * throw/catch types can match Apache CMS Decaf semantics without + * duplicating implementations. + */ + using IndexOutOfBoundsException = OutOfRangeException; + using StringIndexOutOfBoundsException = OutOfRangeException; + using IllegalArgumentException = InvalidArgumentException; + using NumberFormatException = InvalidArgumentException; + +} // namespace exceptions + +} // namespace activemq + +#endif /* _ACTIVEMQ_EXCEPTIONS_EXCEPTIONTYPES_H_ */ diff --git a/activemq-cpp/src/main/activemq/exceptions/IoCatchMacros.h b/activemq-cpp/src/main/activemq/exceptions/IoCatchMacros.h new file mode 100644 index 000000000..d9127779a --- /dev/null +++ b/activemq-cpp/src/main/activemq/exceptions/IoCatchMacros.h @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _ACTIVEMQ_EXCEPTIONS_IOCATCHMACROS_H_ +#define _ACTIVEMQ_EXCEPTIONS_IOCATCHMACROS_H_ + +#include +#include +#include + +#include +#include +#include +#include + +/** + * Map Decaf stream exceptions raised inside decaf/ to activemq::exceptions + * types used throughout activemq/. Also rethrow ActiveMQ I/O exceptions. + */ +#define AMQ_IOSTREAM_CATCH_RETHROW() \ + catch (::decaf::io::EOFException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw ::activemq::exceptions::EOFException(__FILE__, \ + __LINE__, \ + ex.getMessage()); \ + } \ + catch (::decaf::io::UTFDataFormatException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw ::activemq::exceptions::UTFDataFormatException(__FILE__, \ + __LINE__, \ + ex.getMessage()); \ + } \ + catch (::decaf::io::InterruptedIOException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw ::activemq::exceptions::InterruptedIOException(__FILE__, \ + __LINE__, \ + ex.getMessage()); \ + } \ + catch (::decaf::io::IOException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw ::activemq::exceptions::IOException(__FILE__, \ + __LINE__, \ + ex.getMessage()); \ + } \ + catch (::activemq::exceptions::EOFException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw; \ + } \ + catch (::activemq::exceptions::UTFDataFormatException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw; \ + } \ + catch (::activemq::exceptions::InterruptedIOException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw; \ + } \ + catch (::activemq::exceptions::IOException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw; \ + } + +#define AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() \ + catch (::activemq::exceptions::ActiveMQException & ex) \ + { \ + ::activemq::exceptions::IOException target(ex); \ + target.setMark(__FILE__, __LINE__); \ + throw target; \ + } + +#define AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() \ + catch (::decaf::lang::Exception & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw ::activemq::exceptions::IOException(ex); \ + } + +#define AMQ_IOSTREAM_CATCHALL_THROW() \ + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() \ + catch (...) \ + { \ + throw ::activemq::exceptions::IOException(__FILE__, \ + __LINE__, \ + "caught unknown exception"); \ + } + +#endif /* _ACTIVEMQ_EXCEPTIONS_IOCATCHMACROS_H_ */ diff --git a/activemq-cpp/src/main/activemq/exceptions/IoExceptions.cpp b/activemq-cpp/src/main/activemq/exceptions/IoExceptions.cpp new file mode 100644 index 000000000..8b14f81ba --- /dev/null +++ b/activemq-cpp/src/main/activemq/exceptions/IoExceptions.cpp @@ -0,0 +1,339 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include + +using activemq::exceptions::EOFException; +using activemq::exceptions::InterruptedIOException; +using activemq::exceptions::IOException; +using activemq::exceptions::Throwable; +using activemq::exceptions::UnsupportedEncodingException; +using activemq::exceptions::UTFDataFormatException; + +namespace +{ + +std::string formatVariadic(const char* file, + int lineNumber, + const char* fmt, + va_list args) +{ + char buffer[8192]; + int n = vsnprintf(buffer, sizeof(buffer), fmt, args); + std::string text; + if (n >= 0 && n < (int)sizeof(buffer)) + { + text.assign(buffer, (std::size_t)n); + } + else if (n >= (int)sizeof(buffer)) + { + text.assign(buffer, sizeof(buffer) - 1); + } + else + { + text = "(IoExceptions format error)"; + } + return activemq::exceptions::buildSourceMessage(file, lineNumber, text); +} + +} // namespace + +//////////////////////////////////////////////////////////////////////////////// +Throwable::~Throwable() throw() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Throwable::Throwable() + : std::runtime_error("") +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Throwable::Throwable(const std::string& message) + : std::runtime_error(message) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Throwable::Throwable(const char* file, + int lineNumber, + const std::string& message) + : std::runtime_error( + activemq::exceptions::buildSourceMessage(file, lineNumber, message)) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +std::string Throwable::getMessage() const +{ + return std::string(this->what()); +} + +//////////////////////////////////////////////////////////////////////////////// +IOException::~IOException() throw() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +IOException::IOException() + : Throwable() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +IOException::IOException(const char* file, + int lineNumber, + const std::string& message) + : Throwable(file, lineNumber, message) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +IOException::IOException(const char* file, int lineNumber, const char* fmt, ...) + : Throwable() +{ + va_list ap; + va_start(ap, fmt); + std::string composed = formatVariadic(file, lineNumber, fmt, ap); + va_end(ap); + std::string full = + activemq::exceptions::buildSourceMessage(file, lineNumber, composed); + *static_cast(this) = std::runtime_error(full); +} + +//////////////////////////////////////////////////////////////////////////////// +IOException::IOException(const decaf::lang::Exception& ex) + : Throwable(ex.getMessage()) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +IOException::IOException(const IOException& other) + : Throwable(other.getMessage()) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +IOException& IOException::operator=(const IOException& other) +{ + if (this != &other) + { + static_cast(*this) = + std::runtime_error(other.what()); + } + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +EOFException::~EOFException() throw() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +EOFException::EOFException(const char* file, + int lineNumber, + const std::string& message) + : IOException(file, lineNumber, message) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +EOFException::EOFException(const decaf::lang::Exception& ex) + : IOException(ex) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +EOFException::EOFException(const EOFException& other) + : IOException(other) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +EOFException& EOFException::operator=(const EOFException& other) +{ + IOException::operator=(other); + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +InterruptedIOException::~InterruptedIOException() throw() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +InterruptedIOException::InterruptedIOException() + : IOException() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +InterruptedIOException::InterruptedIOException(const char* file, + int lineNumber, + const std::string& message) + : IOException(file, lineNumber, message) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +InterruptedIOException::InterruptedIOException(const char* file, + int lineNumber, + const char* fmt, + ...) + : IOException() +{ + va_list ap; + va_start(ap, fmt); + std::string composed = formatVariadic(file, lineNumber, fmt, ap); + va_end(ap); + std::string full = + activemq::exceptions::buildSourceMessage(file, lineNumber, composed); + *static_cast(this) = std::runtime_error(full); +} + +//////////////////////////////////////////////////////////////////////////////// +InterruptedIOException::InterruptedIOException(const decaf::lang::Exception& ex) + : IOException(ex) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +InterruptedIOException::InterruptedIOException( + const InterruptedIOException& other) + : IOException(other) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +InterruptedIOException& InterruptedIOException::operator=( + const InterruptedIOException& other) +{ + IOException::operator=(other); + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +UTFDataFormatException::~UTFDataFormatException() throw() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +UTFDataFormatException::UTFDataFormatException(const char* file, + int lineNumber, + const std::string& message) + : IOException(file, lineNumber, message) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +UTFDataFormatException::UTFDataFormatException(const char* file, + int lineNumber, + const char* fmt, + ...) + : IOException() +{ + va_list ap; + va_start(ap, fmt); + std::string composed = formatVariadic(file, lineNumber, fmt, ap); + va_end(ap); + std::string full = + activemq::exceptions::buildSourceMessage(file, lineNumber, composed); + *static_cast(this) = std::runtime_error(full); +} + +//////////////////////////////////////////////////////////////////////////////// +UTFDataFormatException::UTFDataFormatException(const decaf::lang::Exception& ex) + : IOException(ex) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +UTFDataFormatException::UTFDataFormatException( + const UTFDataFormatException& other) + : IOException(other) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +UTFDataFormatException& UTFDataFormatException::operator=( + const UTFDataFormatException& other) +{ + IOException::operator=(other); + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +UnsupportedEncodingException::~UnsupportedEncodingException() throw() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +UnsupportedEncodingException::UnsupportedEncodingException() + : IOException() +{ +} + +//////////////////////////////////////////////////////////////////////////////// +UnsupportedEncodingException::UnsupportedEncodingException( + const char* file, + int lineNumber, + const std::string& message) + : IOException(file, lineNumber, message) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +UnsupportedEncodingException::UnsupportedEncodingException(const char* file, + int lineNumber, + const char* fmt, + ...) + : IOException() +{ + va_list ap; + va_start(ap, fmt); + std::string composed = formatVariadic(file, lineNumber, fmt, ap); + va_end(ap); + std::string full = + activemq::exceptions::buildSourceMessage(file, lineNumber, composed); + *static_cast(this) = std::runtime_error(full); +} + +//////////////////////////////////////////////////////////////////////////////// +UnsupportedEncodingException::UnsupportedEncodingException( + const decaf::lang::Exception& ex) + : IOException(ex) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +UnsupportedEncodingException::UnsupportedEncodingException( + const UnsupportedEncodingException& other) + : IOException(other) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +UnsupportedEncodingException& UnsupportedEncodingException::operator=( + const UnsupportedEncodingException& other) +{ + IOException::operator=(other); + return *this; +} diff --git a/activemq-cpp/src/main/activemq/exceptions/IoExceptions.h b/activemq-cpp/src/main/activemq/exceptions/IoExceptions.h new file mode 100644 index 000000000..cbe86d1e6 --- /dev/null +++ b/activemq-cpp/src/main/activemq/exceptions/IoExceptions.h @@ -0,0 +1,168 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _ACTIVEMQ_EXCEPTIONS_IOEXCEPTIONS_H_ +#define _ACTIVEMQ_EXCEPTIONS_IOEXCEPTIONS_H_ + +#include +#include + +#include + +#include +#include + +namespace activemq +{ +namespace exceptions +{ + + /** + * Minimal Throwable base for migrated ActiveMQ I/O errors (std::exception). + * setMark is a no-op so legacy AMQ_CATCH_RETHROW(...) macros remain usable. + */ + class AMQCPP_API Throwable : public std::runtime_error + { + protected: + Throwable(); + + public: + virtual ~Throwable() throw(); + + explicit Throwable(const std::string& message); + Throwable(const char* file, int lineNumber, const std::string& message); + + virtual void setMark(const char* file AMQCPP_UNUSED, + int lineNumber AMQCPP_UNUSED) + { + } + + std::string getMessage() const; + }; + + /** + * ActiveMQ-level replacement for decaf::io::IOException outside decaf/. + */ + class AMQCPP_API IOException : public Throwable + { + public: + virtual ~IOException() throw(); + + IOException(); + + IOException(const char* file, + int lineNumber, + const std::string& message); + IOException(const char* file, int lineNumber, const char* fmt, ...); + explicit IOException(const decaf::lang::Exception& ex); + + IOException(const IOException& other); + IOException& operator=(const IOException& other); + }; + + /** + * ActiveMQ-level replacement for decaf::io::EOFException outside decaf/. + */ + class AMQCPP_API EOFException : public IOException + { + public: + virtual ~EOFException() throw(); + + EOFException(const char* file, + int lineNumber, + const std::string& message); + explicit EOFException(const decaf::lang::Exception& ex); + + EOFException(const EOFException& other); + EOFException& operator=(const EOFException& other); + }; + + /** + * ActiveMQ-level replacement for decaf::io::InterruptedIOException + * outside decaf/. + */ + class AMQCPP_API InterruptedIOException : public IOException + { + public: + virtual ~InterruptedIOException() throw(); + + InterruptedIOException(); + + InterruptedIOException(const char* file, + int lineNumber, + const std::string& message); + InterruptedIOException(const char* file, + int lineNumber, + const char* fmt, + ...); + explicit InterruptedIOException(const decaf::lang::Exception& ex); + + InterruptedIOException(const InterruptedIOException& other); + InterruptedIOException& operator=(const InterruptedIOException& other); + }; + + /** + * ActiveMQ-level replacement for decaf::io::UTFDataFormatException + * outside decaf/. + */ + class AMQCPP_API UTFDataFormatException : public IOException + { + public: + virtual ~UTFDataFormatException() throw(); + + UTFDataFormatException(const char* file, + int lineNumber, + const std::string& message); + UTFDataFormatException(const char* file, + int lineNumber, + const char* fmt, + ...); + explicit UTFDataFormatException(const decaf::lang::Exception& ex); + + UTFDataFormatException(const UTFDataFormatException& other); + UTFDataFormatException& operator=(const UTFDataFormatException& other); + }; + + /** + * ActiveMQ-level replacement for decaf::io::UnsupportedEncodingException + * outside decaf/. + */ + class AMQCPP_API UnsupportedEncodingException : public IOException + { + public: + virtual ~UnsupportedEncodingException() throw(); + + UnsupportedEncodingException(); + + UnsupportedEncodingException(const char* file, + int lineNumber, + const std::string& message); + UnsupportedEncodingException(const char* file, + int lineNumber, + const char* fmt, + ...); + explicit UnsupportedEncodingException(const decaf::lang::Exception& ex); + + UnsupportedEncodingException(const UnsupportedEncodingException& other); + UnsupportedEncodingException& operator=( + const UnsupportedEncodingException& other); + }; + +} // namespace exceptions +} // namespace activemq + +#endif /* _ACTIVEMQ_EXCEPTIONS_IOEXCEPTIONS_H_ */ diff --git a/activemq-cpp/src/main/activemq/exceptions/StdExceptionCatchMacros.h b/activemq-cpp/src/main/activemq/exceptions/StdExceptionCatchMacros.h new file mode 100644 index 000000000..1aaf60ad4 --- /dev/null +++ b/activemq-cpp/src/main/activemq/exceptions/StdExceptionCatchMacros.h @@ -0,0 +1,222 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _ACTIVEMQ_EXCEPTIONS_STDEXCEPTIONCATCHMACROS_H_ +#define _ACTIVEMQ_EXCEPTIONS_STDEXCEPTIONCATCHMACROS_H_ + +#include + +/** + * Rethrow every STL-backed exception type defined in ExceptionTypes.h + * unchanged. Use in place of catch (std::logic_error&) / catch + * (std::runtime_error&) when those catches only existed to propagate AMQ + * thin exception wrappers. + */ +#define AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() \ + catch (::activemq::exceptions::IllegalStateException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::InvalidStateException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::CloneNotSupportedException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::NullPointerException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::UnsupportedOperationException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::IllegalMonitorStateException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::TypeMismatchException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::OutOfRangeException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::InvalidArgumentException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::InterruptedException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::RuntimeException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::ConcurrentModificationException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::NoSuchElementException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::OutOfMemoryError&) \ + { \ + throw; \ + } + +/** + * Same as AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS but omits + * OutOfRangeException only. Use when an earlier catch maps or handles + * OutOfRangeException and must not be shadowed by this chain. + * InvalidArgumentException remains so std::invalid_argument-backed AMQ + * exceptions still propagate (they are not decaf::lang::Exception subclasses). + */ +#define AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS_AFTER_OUT_OF_RANGE_MAP() \ + catch (::activemq::exceptions::IllegalStateException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::InvalidStateException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::CloneNotSupportedException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::NullPointerException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::UnsupportedOperationException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::IllegalMonitorStateException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::TypeMismatchException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::InvalidArgumentException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::InterruptedException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::RuntimeException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::ConcurrentModificationException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::NoSuchElementException&) \ + { \ + throw; \ + } \ + catch (::activemq::exceptions::OutOfMemoryError&) \ + { \ + throw; \ + } + +/** + * Swallow the same set as AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS without + * rethrowing (destructor / cleanup paths). + */ +#define AMQ_CATCHALL_SWALLOW_STL_BACKED_EXCEPTIONS() \ + catch (::activemq::exceptions::IllegalStateException&) \ + { \ + } \ + catch (::activemq::exceptions::InvalidStateException&) \ + { \ + } \ + catch (::activemq::exceptions::CloneNotSupportedException&) \ + { \ + } \ + catch (::activemq::exceptions::NullPointerException&) \ + { \ + } \ + catch (::activemq::exceptions::UnsupportedOperationException&) \ + { \ + } \ + catch (::activemq::exceptions::IllegalMonitorStateException&) \ + { \ + } \ + catch (::activemq::exceptions::TypeMismatchException&) \ + { \ + } \ + catch (::activemq::exceptions::OutOfRangeException&) \ + { \ + } \ + catch (::activemq::exceptions::InvalidArgumentException&) \ + { \ + } \ + catch (::activemq::exceptions::InterruptedException&) \ + { \ + } \ + catch (::activemq::exceptions::RuntimeException&) \ + { \ + } \ + catch (::activemq::exceptions::ConcurrentModificationException&) \ + { \ + } \ + catch (::activemq::exceptions::NoSuchElementException&) \ + { \ + } \ + catch (::activemq::exceptions::OutOfMemoryError&) \ + { \ + } + +/** + * Run \p cleanup_stmt then rethrow for AMQ exceptions that derive from + * std::runtime_error (used by lock acquire paths after cancelAcquire). + */ +#define AMQ_CANCEL_AND_RETHROW_RUNTIME_HIERARCHY(cleanup_stmt) \ + catch (::activemq::exceptions::InterruptedException&) \ + { \ + cleanup_stmt; \ + throw; \ + } \ + catch (::activemq::exceptions::RuntimeException&) \ + { \ + cleanup_stmt; \ + throw; \ + } \ + catch (::activemq::exceptions::ConcurrentModificationException&) \ + { \ + cleanup_stmt; \ + throw; \ + } \ + catch (::activemq::exceptions::NoSuchElementException&) \ + { \ + cleanup_stmt; \ + throw; \ + } + +#endif /* _ACTIVEMQ_EXCEPTIONS_STDEXCEPTIONCATCHMACROS_H_ */ diff --git a/activemq-cpp/src/main/activemq/io/LoggingInputStream.cpp b/activemq-cpp/src/main/activemq/io/LoggingInputStream.cpp index 68a7b501f..85406ba10 100644 --- a/activemq-cpp/src/main/activemq/io/LoggingInputStream.cpp +++ b/activemq-cpp/src/main/activemq/io/LoggingInputStream.cpp @@ -16,15 +16,15 @@ */ #include "LoggingInputStream.h" -#include +#include #include #include +#include using namespace std; using namespace activemq; using namespace activemq::io; using namespace decaf::io; -using namespace decaf::lang::exceptions; LOGDECAF_INITIALIZE(logger, LoggingInputStream, @@ -45,14 +45,9 @@ LoggingInputStream::~LoggingInputStream() //////////////////////////////////////////////////////////////////////////////// int LoggingInputStream::doReadByte() { - try - { - unsigned char c = (unsigned char)FilterInputStream::doReadByte(); - log(&c, 1); - return c; - } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCHALL_THROW(IOException) + unsigned char c = (unsigned char)FilterInputStream::doReadByte(); + log(&c, 1); + return c; } //////////////////////////////////////////////////////////////////////////////// @@ -61,43 +56,30 @@ int LoggingInputStream::doReadArrayBounded(unsigned char* buffer, int offset, int length) { - try + if (length == 0) { - if (length == 0) - { - return 0; - } + return 0; + } - if (buffer == NULL) - { - throw NullPointerException( - __FILE__, - __LINE__, - "LoggingInputStream::read - Passed Buffer is Null"); - } + if (buffer == NULL) + { + throw activemq::exceptions::NullPointerException( + "LoggingInputStream::read - Passed Buffer is Null"); + } - if (length > size - offset) - { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Given size{%d} - offset{%d} is less than length{%d}.", - size, - offset, - length); - } + if (length > size - offset) + { + throw activemq::exceptions::OutOfRangeException( + "Given size - offset is less than length for " + "LoggingInputStream::read"); + } - int numRead = - FilterInputStream::doReadArrayBounded(buffer, size, offset, length); + int numRead = + FilterInputStream::doReadArrayBounded(buffer, size, offset, length); - log(buffer, numRead); + log(buffer, numRead); - return (int)numRead; - } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_RETHROW(IndexOutOfBoundsException) - AMQ_CATCH_RETHROW(NullPointerException) - AMQ_CATCHALL_THROW(IOException) + return numRead; } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/io/LoggingInputStream.h b/activemq-cpp/src/main/activemq/io/LoggingInputStream.h index 0edfbd87f..7ea5a7145 100644 --- a/activemq-cpp/src/main/activemq/io/LoggingInputStream.h +++ b/activemq-cpp/src/main/activemq/io/LoggingInputStream.h @@ -20,7 +20,6 @@ #include #include -#include #include namespace activemq diff --git a/activemq-cpp/src/main/activemq/io/LoggingOutputStream.cpp b/activemq-cpp/src/main/activemq/io/LoggingOutputStream.cpp index 378a60217..15bbe18b7 100644 --- a/activemq-cpp/src/main/activemq/io/LoggingOutputStream.cpp +++ b/activemq-cpp/src/main/activemq/io/LoggingOutputStream.cpp @@ -16,15 +16,15 @@ */ #include "LoggingOutputStream.h" -#include +#include #include #include +#include using namespace std; using namespace activemq; using namespace activemq::io; using namespace decaf::io; -using namespace decaf::lang::exceptions; LOGDECAF_INITIALIZE(logger, LoggingOutputStream, @@ -44,13 +44,8 @@ LoggingOutputStream::~LoggingOutputStream() //////////////////////////////////////////////////////////////////////////////// void LoggingOutputStream::doWriteByte(const unsigned char c) { - try - { - log(&c, 1); - FilterOutputStream::doWriteByte(c); - } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCHALL_THROW(IOException) + log(&c, 1); + FilterOutputStream::doWriteByte(c); } //////////////////////////////////////////////////////////////////////////////// @@ -59,38 +54,27 @@ void LoggingOutputStream::doWriteArrayBounded(const unsigned char* buffer, int offset, int length) { - try + if (length == 0) { - if (length == 0) - { - return; - } + return; + } - if (buffer == NULL) - { - throw NullPointerException( - __FILE__, - __LINE__, - "LoggingOutputStream::write - Passed Buffer is Null"); - } + if (buffer == NULL) + { + throw activemq::exceptions::NullPointerException( + "LoggingOutputStream::write - Passed Buffer is Null"); + } - if ((offset + length) > size) - { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "DataOutputStream::write - given offset + length is greater " - "than buffer size."); - } + if ((offset + length) > size) + { + throw activemq::exceptions::IndexOutOfBoundsException( + "DataOutputStream::write - given offset + length is greater " + "than buffer size."); + } - log(buffer + offset, length); + log(buffer + offset, length); - FilterOutputStream::doWriteArrayBounded(buffer, size, offset, length); - } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_RETHROW(NullPointerException) - AMQ_CATCH_RETHROW(IndexOutOfBoundsException) - AMQ_CATCHALL_THROW(IOException) + FilterOutputStream::doWriteArrayBounded(buffer, size, offset, length); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/state/ConnectionState.cpp b/activemq-cpp/src/main/activemq/state/ConnectionState.cpp index f931b6645..350ac38b2 100644 --- a/activemq-cpp/src/main/activemq/state/ConnectionState.cpp +++ b/activemq-cpp/src/main/activemq/state/ConnectionState.cpp @@ -17,11 +17,13 @@ #include "ConnectionState.h" -#include - #include #include +#include +#include +#include + using namespace activemq; using namespace activemq::state; using namespace activemq::commands; @@ -94,7 +96,7 @@ void ConnectionState::checkShutdown() const { if (this->disposed.load()) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Connection already Disposed"); diff --git a/activemq-cpp/src/main/activemq/state/ConnectionStateTracker.cpp b/activemq-cpp/src/main/activemq/state/ConnectionStateTracker.cpp index 26b6f8b0f..bbfa104c9 100644 --- a/activemq-cpp/src/main/activemq/state/ConnectionStateTracker.cpp +++ b/activemq-cpp/src/main/activemq/state/ConnectionStateTracker.cpp @@ -21,8 +21,9 @@ #include #include #include -#include #include +#include +#include #include #include @@ -40,7 +41,6 @@ using namespace decaf; using namespace decaf::lang; using namespace decaf::util; using namespace decaf::io; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace activemq @@ -237,9 +237,9 @@ std::shared_ptr ConnectionStateTracker::track( return std::dynamic_pointer_cast(result); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -311,9 +311,9 @@ void ConnectionStateTracker::restore( transport->oneway(messagePullIter->next()); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -391,9 +391,9 @@ void ConnectionStateTracker::doRestoreTransactions( transport->getTransportListener()->onCommand(response); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -421,9 +421,9 @@ void ConnectionStateTracker::doRestoreSessions( } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -464,9 +464,9 @@ void ConnectionStateTracker::doRestoreConsumers( transport->oneway(infoToSend); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -485,9 +485,9 @@ void ConnectionStateTracker::doRestoreProducers( transport->oneway(state->getInfo()); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -505,9 +505,9 @@ void ConnectionStateTracker::doRestoreTempDestinations( transport->oneway(iter->next()); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -700,7 +700,7 @@ std::shared_ptr ConnectionStateTracker::processRemoveConsumer( { cs->getRecoveringPullConsumers().remove(consumerId); } - catch (NoSuchElementException e) + catch (NoSuchElementException&) { } } @@ -1147,7 +1147,7 @@ void ConnectionStateTracker::connectionInterruptProcessingComplete( { transport->oneway(control); } - catch (Exception& ex) + catch (const std::exception&) { } } diff --git a/activemq-cpp/src/main/activemq/state/SessionState.cpp b/activemq-cpp/src/main/activemq/state/SessionState.cpp index 5b904b3fc..40029ac3f 100644 --- a/activemq-cpp/src/main/activemq/state/SessionState.cpp +++ b/activemq-cpp/src/main/activemq/state/SessionState.cpp @@ -19,7 +19,9 @@ #include -#include +#include +#include +#include #include @@ -70,7 +72,7 @@ void SessionState::checkShutdown() const { if (this->disposed.load()) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Session already Disposed"); diff --git a/activemq-cpp/src/main/activemq/state/TransactionState.cpp b/activemq-cpp/src/main/activemq/state/TransactionState.cpp index 317f23c23..5e83983e4 100644 --- a/activemq-cpp/src/main/activemq/state/TransactionState.cpp +++ b/activemq-cpp/src/main/activemq/state/TransactionState.cpp @@ -19,7 +19,9 @@ #include -#include +#include +#include +#include using namespace activemq; using namespace activemq::commands; @@ -85,7 +87,7 @@ void TransactionState::checkShutdown() const { if (this->disposed.load()) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Transaction already Disposed"); diff --git a/activemq-cpp/src/main/activemq/threads/CompositeTaskRunner.cpp b/activemq-cpp/src/main/activemq/threads/CompositeTaskRunner.cpp index 96d83914d..b760b8cfe 100644 --- a/activemq-cpp/src/main/activemq/threads/CompositeTaskRunner.cpp +++ b/activemq-cpp/src/main/activemq/threads/CompositeTaskRunner.cpp @@ -29,7 +29,6 @@ using namespace activemq::exceptions; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace activemq diff --git a/activemq-cpp/src/main/activemq/threads/DedicatedTaskRunner.cpp b/activemq-cpp/src/main/activemq/threads/DedicatedTaskRunner.cpp index c8ca6f2cf..770e05205 100644 --- a/activemq-cpp/src/main/activemq/threads/DedicatedTaskRunner.cpp +++ b/activemq-cpp/src/main/activemq/threads/DedicatedTaskRunner.cpp @@ -18,14 +18,15 @@ #include "DedicatedTaskRunner.h" #include -#include +#include +#include +#include using namespace activemq; using namespace activemq::threads; using namespace activemq::exceptions; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// DedicatedTaskRunner::DedicatedTaskRunner(Task* task) @@ -37,7 +38,10 @@ DedicatedTaskRunner::DedicatedTaskRunner(Task* task) { if (this->task == NULL) { - throw NullPointerException(__FILE__, __LINE__, "Task passed was null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Task passed was null"); } this->thread.reset(new Thread(this, "ActiveMQ Dedicated Task Runner")); diff --git a/activemq-cpp/src/main/activemq/threads/Scheduler.cpp b/activemq-cpp/src/main/activemq/threads/Scheduler.cpp index fc191b2b0..97794b929 100644 --- a/activemq-cpp/src/main/activemq/threads/Scheduler.cpp +++ b/activemq-cpp/src/main/activemq/threads/Scheduler.cpp @@ -22,10 +22,12 @@ #include #include -#include -#include #include +#include +#include +#include + using namespace activemq; using namespace activemq::threads; using namespace activemq::util; @@ -34,7 +36,6 @@ using namespace decaf; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// Scheduler::Scheduler(const std::string& name) @@ -45,9 +46,9 @@ Scheduler::Scheduler(const std::string& name) { if (name.empty()) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Scheduler name must not be empty."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Scheduler name must not be empty."); } } @@ -75,9 +76,10 @@ void Scheduler::executePeriodically(Runnable* task, { if (!isStarted()) { - throw IllegalStateException(__FILE__, - __LINE__, - "Scheduler is not started."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Scheduler is not started."); } synchronized(&mutex) @@ -95,9 +97,10 @@ void Scheduler::schedualPeriodically(Runnable* task, { if (!isStarted()) { - throw IllegalStateException(__FILE__, - __LINE__, - "Scheduler is not started."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Scheduler is not started."); } synchronized(&mutex) @@ -113,9 +116,10 @@ void Scheduler::cancel(Runnable* task) { if (!isStarted()) { - throw IllegalStateException(__FILE__, - __LINE__, - "Scheduler is not started."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Scheduler is not started."); } synchronized(&mutex) @@ -136,9 +140,10 @@ void Scheduler::executeAfterDelay(Runnable* task, { if (!isStarted()) { - throw IllegalStateException(__FILE__, - __LINE__, - "Scheduler is not started."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Scheduler is not started."); } synchronized(&mutex) diff --git a/activemq-cpp/src/main/activemq/threads/SchedulerTimerTask.cpp b/activemq-cpp/src/main/activemq/threads/SchedulerTimerTask.cpp index fa4095b07..67b10481f 100644 --- a/activemq-cpp/src/main/activemq/threads/SchedulerTimerTask.cpp +++ b/activemq-cpp/src/main/activemq/threads/SchedulerTimerTask.cpp @@ -18,14 +18,15 @@ #include "SchedulerTimerTask.h" #include -#include +#include +#include +#include using namespace activemq; using namespace activemq::threads; using namespace activemq::exceptions; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// SchedulerTimerTask::SchedulerTimerTask(Runnable* task, bool ownsTask) @@ -34,9 +35,10 @@ SchedulerTimerTask::SchedulerTimerTask(Runnable* task, bool ownsTask) { if (task == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Assigned Task cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Assigned Task cannot be NULL."); } } diff --git a/activemq-cpp/src/main/activemq/transport/AbstractTransportFactory.cpp b/activemq-cpp/src/main/activemq/transport/AbstractTransportFactory.cpp index 1b7bd5528..da210457d 100644 --- a/activemq-cpp/src/main/activemq/transport/AbstractTransportFactory.cpp +++ b/activemq-cpp/src/main/activemq/transport/AbstractTransportFactory.cpp @@ -17,10 +17,13 @@ #include "AbstractTransportFactory.h" +#include +#include #include #include #include #include +#include #include #include @@ -32,7 +35,6 @@ using namespace activemq::wireformat; using namespace activemq::exceptions; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::net; using namespace decaf::util; @@ -53,7 +55,16 @@ std::shared_ptr AbstractTransportFactory::createWireFormat( WireFormatRegistry::getInstance().findFactory(wireFormat); return factory->createWireFormat(properties); } - AMQ_CATCH_RETHROW(NoSuchElementException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, NoSuchElementException) - AMQ_CATCHALL_THROW(NoSuchElementException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + catch (const std::exception& ex) + { + throw activemq::exceptions::InterruptedException(ex.what()); + } + catch (...) + { + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } diff --git a/activemq-cpp/src/main/activemq/transport/AbstractTransportFactory.h b/activemq-cpp/src/main/activemq/transport/AbstractTransportFactory.h index 5689e0508..a087d4f8e 100644 --- a/activemq-cpp/src/main/activemq/transport/AbstractTransportFactory.h +++ b/activemq-cpp/src/main/activemq/transport/AbstractTransportFactory.h @@ -22,9 +22,9 @@ #include #include #include -#include #include #include +#include namespace activemq { @@ -53,7 +53,7 @@ namespace transport * * @return a pointer to a WireFormat instance that the caller then owns. * - * @throws NoSuchElementException if the configured WireFormat is not + * @throws std::runtime_error if the configured WireFormat is not * found. */ virtual std::shared_ptr createWireFormat( diff --git a/activemq-cpp/src/main/activemq/transport/FutureResponse.cpp b/activemq-cpp/src/main/activemq/transport/FutureResponse.cpp index 4925bbf5e..08f28bc84 100644 --- a/activemq-cpp/src/main/activemq/transport/FutureResponse.cpp +++ b/activemq-cpp/src/main/activemq/transport/FutureResponse.cpp @@ -19,8 +19,9 @@ #include #include -#include #include +#include +#include #include using namespace activemq; @@ -28,9 +29,7 @@ using namespace activemq::transport; using namespace activemq::exceptions; using namespace activemq::commands; using namespace decaf; -using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util::concurrent; //////////////////////////////////////////////////////////////////////////////// @@ -63,13 +62,13 @@ std::shared_ptr FutureResponse::getResponse() const this->responseLatch.await(); return response; } - catch (decaf::lang::exceptions::InterruptedException& ex) + catch (InterruptedException&) { decaf::lang::Thread::currentThread()->interrupt(); - throw decaf::io::InterruptedIOException( + throw InterruptedIOException( __FILE__, __LINE__, - "Interrupted while awaiting a response"); + std::string("Interrupted while awaiting a response")); } } @@ -81,13 +80,13 @@ std::shared_ptr FutureResponse::getResponse() this->responseLatch.await(); return response; } - catch (decaf::lang::exceptions::InterruptedException& ex) + catch (InterruptedException&) { decaf::lang::Thread::currentThread()->interrupt(); - throw decaf::io::InterruptedIOException( + throw InterruptedIOException( __FILE__, __LINE__, - "Interrupted while awaiting a response"); + std::string("Interrupted while awaiting a response")); } } @@ -99,12 +98,12 @@ std::shared_ptr FutureResponse::getResponse(unsigned int timeout) cons this->responseLatch.await(timeout); return response; } - catch (decaf::lang::exceptions::InterruptedException& ex) + catch (InterruptedException&) { - throw decaf::io::InterruptedIOException( + throw InterruptedIOException( __FILE__, __LINE__, - "Interrupted while awaiting a response"); + std::string("Interrupted while awaiting a response")); } } @@ -116,12 +115,12 @@ std::shared_ptr FutureResponse::getResponse(unsigned int timeout) this->responseLatch.await(timeout); return response; } - catch (decaf::lang::exceptions::InterruptedException& ex) + catch (InterruptedException&) { - throw decaf::io::InterruptedIOException( + throw InterruptedIOException( __FILE__, __LINE__, - "Interrupted while awaiting a response"); + std::string("Interrupted while awaiting a response")); } } diff --git a/activemq-cpp/src/main/activemq/transport/FutureResponse.h b/activemq-cpp/src/main/activemq/transport/FutureResponse.h index 21648404f..14bde2dd4 100644 --- a/activemq-cpp/src/main/activemq/transport/FutureResponse.h +++ b/activemq-cpp/src/main/activemq/transport/FutureResponse.h @@ -24,12 +24,12 @@ #include #include -#include +#include #include -#include #include #include #include +#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/transport/IOTransport.cpp b/activemq-cpp/src/main/activemq/transport/IOTransport.cpp index e29ef5d1f..49da97f2d 100644 --- a/activemq-cpp/src/main/activemq/transport/IOTransport.cpp +++ b/activemq-cpp/src/main/activemq/transport/IOTransport.cpp @@ -23,13 +23,19 @@ #include #include #include +#include +#include #include #include #include #include -#include +#include +#include +#include #include #include +#include +#include #include using namespace activemq; @@ -40,9 +46,7 @@ using namespace activemq::wireformat; using namespace activemq::wireformat::openwire; using activemq::util::AMQLogger; using namespace decaf; -using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -219,15 +223,16 @@ void IOTransport::oneway(const std::shared_ptr command) { if (impl->closed.load()) { - throw IOException(__FILE__, - __LINE__, - "IOTransport::oneway() - transport is closed!"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "IOTransport::oneway() - transport is closed!"); } // Make sure the thread has been started. if (!impl->thread) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "IOTransport::oneway() - transport is not started"); @@ -236,7 +241,7 @@ void IOTransport::oneway(const std::shared_ptr command) // Make sure the command object is valid. if (!command) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "IOTransport::oneway() - attempting to write NULL command"); @@ -245,9 +250,10 @@ void IOTransport::oneway(const std::shared_ptr command) // Make sure we have an output stream to write to. if (impl->outputStream == NULL) { - throw IOException(__FILE__, - __LINE__, - "IOTransport::oneway() - invalid output stream"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "IOTransport::oneway() - invalid output stream"); } AMQ_LOG_DEBUG( @@ -268,9 +274,9 @@ void IOTransport::oneway(const std::shared_ptr command) AMQ_LOG_DEBUG("IOTransport", "oneway() sent cmdId=" << command->getCommandId()); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -283,21 +289,23 @@ void IOTransport::start() { if (impl->closed.load()) { - throw IOException(__FILE__, - __LINE__, - "IOTransport::start() - transport is already " - "closed - cannot restart"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "IOTransport::start() - transport is already " + "closed - cannot restart"); } // Make sure all variables that we need have been set. if (impl->inputStream == NULL || impl->outputStream == NULL || !impl->wireFormat) { - throw IOException(__FILE__, - __LINE__, - "IOTransport::start() - " - "IO streams and wireFormat instances must be " - "set before calling start"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "IOTransport::start() - " + "IO streams and wireFormat instances must be " + "set before calling start"); } // Start the polling thread. @@ -305,9 +313,9 @@ void IOTransport::start() impl->thread->start(); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -317,9 +325,9 @@ void IOTransport::stop() { this->impl->started.store(false); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -361,8 +369,8 @@ void IOTransport::close() // No need to fire anymore async events now. this->impl->listener = NULL; - IOException error; - bool hasException = false; + activemq::exceptions::IOException error; + bool hasException = false; // We have to close the input stream before we stop the thread. this // will force us to wake up the thread if it's stuck in a read @@ -375,9 +383,10 @@ void IOTransport::close() impl->inputStream->close(); } } - catch (IOException& ex) + catch (std::exception& ex) { - error = ex; + decaf::lang::Exception dex(__FILE__, __LINE__, "%s", ex.what()); + error = activemq::exceptions::IOException(dex); error.setMark(__FILE__, __LINE__); hasException = true; } @@ -390,11 +399,15 @@ void IOTransport::close() impl->outputStream->close(); } } - catch (IOException& ex) + catch (std::exception& ex) { if (!hasException) { - error = ex; + decaf::lang::Exception dex(__FILE__, + __LINE__, + "%s", + ex.what()); + error = activemq::exceptions::IOException(dex); error.setMark(__FILE__, __LINE__); hasException = true; } @@ -406,9 +419,9 @@ void IOTransport::close() } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -434,14 +447,43 @@ void IOTransport::run() // Notify the listener. fire(command); } + catch (activemq::exceptions::EOFException& ex) + { + AMQ_LOG_ERROR("IOTransport", + "run() caught EOFException (connection closed): " + << ex.getMessage()); + ActiveMQException wrapped(ex); + wrapped.setMark(__FILE__, __LINE__); + fire(wrapped); + break; + } + catch (activemq::exceptions::IOException& ex) + { + AMQ_LOG_ERROR("IOTransport", + "run() caught IOException: " << ex.getMessage()); + std::string errorMsg = ex.getMessage(); + if (errorMsg.find("OpenSSL") != std::string::npos || + errorMsg.find("SSL") != std::string::npos || + errorMsg.find("TLS") != std::string::npos) + { + AMQ_LOG_ERROR("IOTransport", + "run() SSL/TLS error detected - fatal, " + "propagating to FailoverTransport"); + } + ActiveMQException wrapped(ex); + wrapped.setMark(__FILE__, __LINE__); + fire(wrapped); + break; + } catch (decaf::io::EOFException& ex) { // EOF means connection closed - this is fatal, propagate up AMQ_LOG_ERROR("IOTransport", "run() caught EOFException (connection closed): " << ex.getMessage()); - ex.setMark(__FILE__, __LINE__); - fire(ex); + ActiveMQException wrapped(ex); + wrapped.setMark(__FILE__, __LINE__); + fire(wrapped); break; // Exit the loop, connection is dead } catch (decaf::io::IOException& ex) @@ -463,8 +505,9 @@ void IOTransport::run() "propagating to FailoverTransport"); } - ex.setMark(__FILE__, __LINE__); - fire(ex); + ActiveMQException wrapped(ex); + wrapped.setMark(__FILE__, __LINE__); + fire(wrapped); break; // All IO errors require connection reestablishment } catch (exceptions::ActiveMQException& ex) @@ -477,15 +520,12 @@ void IOTransport::run() fire(ex); break; // Fatal error, exit } - catch (decaf::lang::Exception& ex) + catch (std::exception& ex) { - // Other decaf exceptions indicate connection or protocol - // problems AMQ_LOG_ERROR("IOTransport", - "run() caught Exception: " << ex.getMessage()); + "run() caught Exception: " << ex.what()); - // Check if this is an SSL/TLS error - these are always fatal - std::string errorMsg = ex.getMessage(); + std::string errorMsg(ex.what()); if (errorMsg.find("OpenSSL") != std::string::npos || errorMsg.find("SSL") != std::string::npos || errorMsg.find("TLS") != std::string::npos) @@ -495,9 +535,24 @@ void IOTransport::run() "propagating to FailoverTransport"); } - ex.setMark(__FILE__, __LINE__); - fire(ex); - break; // Propagate to FailoverTransport for reconnection + const decaf::lang::Exception* dex = + dynamic_cast(&ex); + if (dex != nullptr) + { + decaf::lang::Exception copy(*dex); + copy.setMark(__FILE__, __LINE__); + fire(copy); + } + else + { + decaf::lang::Exception wrapped(__FILE__, + __LINE__, + "%s", + errorMsg.c_str()); + wrapped.setMark(__FILE__, __LINE__); + fire(wrapped); + } + break; } catch (...) { @@ -525,12 +580,24 @@ void IOTransport::run() ex.setMark(__FILE__, __LINE__); fire(ex); } - catch (decaf::lang::Exception& ex) + catch (std::exception& ex) { - AMQ_LOG_ERROR("IOTransport", "run() outer catch: " << ex.getMessage()); - exceptions::ActiveMQException exl(ex); - exl.setMark(__FILE__, __LINE__); - fire(exl); + AMQ_LOG_ERROR("IOTransport", "run() outer catch: " << ex.what()); + const decaf::lang::Exception* dex = + dynamic_cast(&ex); + if (dex != nullptr) + { + exceptions::ActiveMQException exl(*dex); + exl.setMark(__FILE__, __LINE__); + fire(exl); + } + else + { + decaf::lang::Exception cause(__FILE__, __LINE__, "%s", ex.what()); + exceptions::ActiveMQException exl(cause); + exl.setMark(__FILE__, __LINE__); + fire(exl); + } } catch (...) { @@ -553,7 +620,7 @@ std::shared_ptr IOTransport::asyncRequest( const std::shared_ptr command AMQCPP_UNUSED, const std::shared_ptr responseCallback AMQCPP_UNUSED) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "IOTransport::asyncRequest() - unsupported operation"); @@ -563,7 +630,7 @@ std::shared_ptr IOTransport::asyncRequest( std::shared_ptr IOTransport::request( const std::shared_ptr command AMQCPP_UNUSED) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "IOTransport::request() - unsupported operation"); @@ -574,7 +641,7 @@ std::shared_ptr IOTransport::request( const std::shared_ptr command AMQCPP_UNUSED, unsigned int timeout AMQCPP_UNUSED) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "IOTransport::request() - unsupported operation"); diff --git a/activemq-cpp/src/main/activemq/transport/IOTransport.h b/activemq-cpp/src/main/activemq/transport/IOTransport.h index ad718d922..bc83d53cd 100644 --- a/activemq-cpp/src/main/activemq/transport/IOTransport.h +++ b/activemq-cpp/src/main/activemq/transport/IOTransport.h @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include namespace activemq { @@ -147,7 +149,7 @@ namespace transport /** * {@inheritDoc} * - * This method always thrown an UnsupportedOperationException. + * This method always thrown std::logic_error. */ virtual std::shared_ptr asyncRequest( const std::shared_ptr command, @@ -156,7 +158,7 @@ namespace transport /** * {@inheritDoc} * - * This method always thrown an UnsupportedOperationException. + * This method always thrown std::logic_error. */ virtual std::shared_ptr request( const std::shared_ptr command); @@ -164,7 +166,7 @@ namespace transport /** * {@inheritDoc} * - * This method always thrown an UnsupportedOperationException. + * This method always thrown std::logic_error. */ virtual std::shared_ptr request( const std::shared_ptr command, @@ -223,7 +225,9 @@ namespace transport const decaf::util::List& uris AMQCPP_UNUSED) { - throw decaf::io::IOException(); + throw activemq::exceptions::IOException(__FILE__, + __LINE__, + "updateURIs not supported"); } /** diff --git a/activemq-cpp/src/main/activemq/transport/Transport.h b/activemq-cpp/src/main/activemq/transport/Transport.h index 8d5450029..5060a30ef 100644 --- a/activemq-cpp/src/main/activemq/transport/Transport.h +++ b/activemq-cpp/src/main/activemq/transport/Transport.h @@ -20,18 +20,18 @@ #include #include +#include #include #include #include #include #include -#include #include #include -#include #include #include #include +#include #include namespace activemq @@ -90,7 +90,7 @@ namespace transport * * @throws IOException if an exception occurs during writing of the * command. - * @throws UnsupportedOperationException if this method is not + * @throws std::logic_error if this method is not * implemented by this transport. */ virtual void oneway(const std::shared_ptr command) = 0; @@ -111,7 +111,7 @@ namespace transport * * @throws IOException if an exception occurs during the read of the * command. - * @throws UnsupportedOperationException if this method is not + * @throws std::logic_error if this method is not * implemented by this transport. */ virtual std::shared_ptr asyncRequest( @@ -128,7 +128,7 @@ namespace transport * * @throws IOException if an exception occurs during the read of the * command. - * @throws UnsupportedOperationException if this method is not + * @throws std::logic_error if this method is not * implemented by this transport. */ virtual std::shared_ptr request( @@ -147,7 +147,7 @@ namespace transport * * @throws IOException if an exception occurs during the read of the * command. - * @throws UnsupportedOperationException if this method is not + * @throws std::logic_error if this method is not * implemented by this transport. */ virtual std::shared_ptr request( diff --git a/activemq-cpp/src/main/activemq/transport/TransportFilter.cpp b/activemq-cpp/src/main/activemq/transport/TransportFilter.cpp index 3b6907698..35b10b5b8 100644 --- a/activemq-cpp/src/main/activemq/transport/TransportFilter.cpp +++ b/activemq-cpp/src/main/activemq/transport/TransportFilter.cpp @@ -16,19 +16,19 @@ */ #include "TransportFilter.h" -#include #include +#include #include #include using namespace activemq; +using namespace activemq::exceptions; using namespace activemq::transport; using namespace decaf::lang; using namespace decaf::util; using namespace decaf::util::concurrent; -using namespace decaf::io; //////////////////////////////////////////////////////////////////////////////// namespace activemq @@ -184,18 +184,11 @@ void TransportFilter::start() return; } - if (this->listener == NULL) - { - throw decaf::io::IOException(__FILE__, - __LINE__, - "exceptionListener is invalid"); - } - if (this->next == NULL) { - throw decaf::io::IOException(__FILE__, - __LINE__, - "Transport chain is invalid"); + throw activemq::exceptions::IOException(__FILE__, + __LINE__, + "Transport chain is invalid"); } try @@ -203,14 +196,33 @@ void TransportFilter::start() bool _e_start = false; if (this->impl->started.compare_exchange_strong(_e_start, true)) { - beforeNextIsStarted(); - next->start(); - afterNextIsStarted(); + try + { + beforeNextIsStarted(); + next->start(); + afterNextIsStarted(); + } + catch (...) + { + // started was set true before the nested chain ran; if any + // stage throws we must run the normal stop teardown (socket, + // reader thread, etc.). Otherwise close()->stop() may see a + // stuck or inconsistent chain and rapid connect tests can crash + // (e.g. SEGV on Linux under load). + try + { + this->stop(); + } + catch (...) + { + } + throw; + } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -228,19 +240,20 @@ void TransportFilter::stop() { if (!this->next) { - throw decaf::io::IOException(__FILE__, - __LINE__, - "Transport chain is invalid"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "Transport chain is invalid"); } - IOException error; - bool hasException = false; + activemq::exceptions::IOException error; + bool hasException = false; try { beforeNextIsStopped(); } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { error = ex; error.setMark(__FILE__, __LINE__); @@ -251,7 +264,7 @@ void TransportFilter::stop() { next->stop(); } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { error = ex; error.setMark(__FILE__, __LINE__); @@ -262,7 +275,7 @@ void TransportFilter::stop() { afterNextIsStopped(); } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { error = ex; error.setMark(__FILE__, __LINE__); @@ -275,9 +288,9 @@ void TransportFilter::stop() } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -290,14 +303,14 @@ void TransportFilter::close() try { - IOException error; - bool hasException = false; + activemq::exceptions::IOException error; + bool hasException = false; try { stop(); } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { error = ex; error.setMark(__FILE__, __LINE__); @@ -309,9 +322,10 @@ void TransportFilter::close() { if (!this->next) { - throw decaf::io::IOException(__FILE__, - __LINE__, - "Transport chain is invalid"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "Transport chain is invalid"); } next->setTransportListener(NULL); @@ -320,7 +334,7 @@ void TransportFilter::close() { next->close(); } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { error = ex; error.setMark(__FILE__, __LINE__); @@ -331,7 +345,7 @@ void TransportFilter::close() { doClose(); } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { error = ex; error.setMark(__FILE__, __LINE__); @@ -344,9 +358,9 @@ void TransportFilter::close() throw error; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -373,9 +387,9 @@ void TransportFilter::reconnect(const decaf::net::URI& uri) { next->reconnect(uri); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -404,6 +418,8 @@ void TransportFilter::checkClosed() const { if (this->impl->closed.load()) { - throw IOException(__FILE__, __LINE__, "Transport is closed"); + throw activemq::exceptions::IOException(__FILE__, + __LINE__, + "Transport is closed"); } } diff --git a/activemq-cpp/src/main/activemq/transport/TransportRegistry.cpp b/activemq-cpp/src/main/activemq/transport/TransportRegistry.cpp index a1f8c6992..5bcefdd58 100644 --- a/activemq-cpp/src/main/activemq/transport/TransportRegistry.cpp +++ b/activemq-cpp/src/main/activemq/transport/TransportRegistry.cpp @@ -17,7 +17,10 @@ #include "TransportRegistry.h" +#include #include +#include +#include using namespace std; using namespace activemq; @@ -25,7 +28,6 @@ using namespace activemq::transport; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace @@ -54,11 +56,11 @@ TransportFactory* TransportRegistry::findFactory(const std::string& name) const { if (!this->registry.containsKey(name)) { - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, - "No Matching Factory Registered for format := %s", - name.c_str()); + std::string("No Matching Factory Registered for format := ") + + name); } return this->registry.get(name); @@ -70,15 +72,14 @@ void TransportRegistry::registerFactory(const std::string& name, { if (name == "") { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "TransportFactory name cannot be the empty string"); } if (factory == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Supplied TransportFactory pointer was NULL"); diff --git a/activemq-cpp/src/main/activemq/transport/TransportRegistry.h b/activemq-cpp/src/main/activemq/transport/TransportRegistry.h index ece8276be..1f3555ad4 100644 --- a/activemq-cpp/src/main/activemq/transport/TransportRegistry.h +++ b/activemq-cpp/src/main/activemq/transport/TransportRegistry.h @@ -24,10 +24,8 @@ #include #include -#include -#include -#include #include +#include namespace activemq { @@ -69,7 +67,7 @@ namespace transport * * @return the Factory registered under the given name. * - * @throws NoSuchElementException if no factory is registered with that + * @throws std::runtime_error if no factory is registered with that * name. */ TransportFactory* findFactory(const std::string& name) const; @@ -86,8 +84,8 @@ namespace transport * @param factory * The new Factory to add to the Registry. * - * @throws IllegalArgumentException is name is the empty string. - * @throws NullPointerException if the Factory is Null. + * @throws std::invalid_argument is name is the empty string. + * @throws std::logic_error if the Factory is Null. */ void registerFactory(const std::string& name, TransportFactory* factory); diff --git a/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.cpp b/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.cpp index 89be682aa..0e8e6e275 100644 --- a/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.cpp +++ b/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.cpp @@ -18,6 +18,7 @@ #include "ResponseCorrelator.h" #include +#include #include #include #include @@ -26,8 +27,13 @@ #include #include +#include +#include +#include #include #include +#include +#include using namespace std; using namespace activemq; @@ -36,9 +42,7 @@ using namespace activemq::transport::correlator; using namespace activemq::exceptions; using activemq::util::AMQLogger; using namespace decaf; -using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -73,7 +77,7 @@ class ResponseFinalizer synchronized(mutex) { // Only remove if the key still exists to avoid - // NoSuchElementException + // std::runtime_error if (map->containsKey(commandId)) { try @@ -157,11 +161,12 @@ void ResponseCorrelator::oneway(const std::shared_ptr command) next->oneway(command); } - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -202,9 +207,10 @@ std::shared_ptr ResponseCorrelator::asyncRequest( futureResponse->setResponse(response); - throw IOException(__FILE__, - __LINE__, - this->impl->priorError->getMessage().c_str()); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + this->impl->priorError->getMessage().c_str()); } // Send the request. @@ -212,7 +218,7 @@ std::shared_ptr ResponseCorrelator::asyncRequest( { next->oneway(command); } - catch (Exception& ex) + catch (const std::exception&) { // We have to ensure this gets cleaned out otherwise we can consume // memory over time. @@ -234,11 +240,12 @@ std::shared_ptr ResponseCorrelator::asyncRequest( return futureResponse; } - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } std::shared_ptr ResponseCorrelator::request( @@ -285,9 +292,10 @@ std::shared_ptr ResponseCorrelator::request( if (priorError) { - throw IOException(__FILE__, - __LINE__, - this->impl->priorError->getMessage().c_str()); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + this->impl->priorError->getMessage().c_str()); } // The finalizer will cleanup the map even if an exception is thrown. @@ -306,7 +314,7 @@ std::shared_ptr ResponseCorrelator::request( if (!response) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "No valid response received for command: %s, check broker.", @@ -315,11 +323,12 @@ std::shared_ptr ResponseCorrelator::request( return response; } - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } std::shared_ptr ResponseCorrelator::request( @@ -350,9 +359,10 @@ std::shared_ptr ResponseCorrelator::request( if (priorError) { - throw IOException(__FILE__, - __LINE__, - this->impl->priorError->getMessage().c_str()); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + this->impl->priorError->getMessage().c_str()); } // The finalizer will cleanup the map even if an exception is thrown. @@ -371,7 +381,7 @@ std::shared_ptr ResponseCorrelator::request( if (!response) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "No valid response received for command: %s, check broker.", @@ -380,11 +390,12 @@ std::shared_ptr ResponseCorrelator::request( return response; } - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -426,7 +437,7 @@ void ResponseCorrelator::onCommand(const std::shared_ptr command) << response->getCorrelationId() << " mapSize=" << this->impl->requestMap.size()); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { AMQ_LOG_DEBUG("ResponseCorrelator", "NOT FOUND in map correlationId=" @@ -454,7 +465,7 @@ void ResponseCorrelator::onCommand(const std::shared_ptr command) // during reconnection if (!this->impl->priorError) { - this->impl->priorError.reset(new IOException( + this->impl->priorError.reset(new ActiveMQException( __FILE__, __LINE__, exResponse->getException()->getMessage().c_str())); @@ -479,11 +490,11 @@ void ResponseCorrelator::doClose() try { dispose(std::shared_ptr( - new IOException(__FILE__, __LINE__, "Transport Stopped"))); + new ActiveMQException(__FILE__, __LINE__, "Transport Stopped"))); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.h b/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.h index 5d6f6bf8d..b649e3113 100644 --- a/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.h +++ b/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.h @@ -63,7 +63,7 @@ namespace transport * @param next * the next transport in the chain * - * @throws NullPointerException if next if NULL. + * @throws std::logic_error if next if NULL. */ ResponseCorrelator(std::shared_ptr next); diff --git a/activemq-cpp/src/main/activemq/transport/discovery/AbstractDiscoveryAgent.cpp b/activemq-cpp/src/main/activemq/transport/discovery/AbstractDiscoveryAgent.cpp index 91e81c525..e4ffc2b6f 100644 --- a/activemq-cpp/src/main/activemq/transport/discovery/AbstractDiscoveryAgent.cpp +++ b/activemq-cpp/src/main/activemq/transport/discovery/AbstractDiscoveryAgent.cpp @@ -17,6 +17,7 @@ #include +#include #include #include @@ -30,14 +31,15 @@ #include #include #include +#include using namespace activemq; +using namespace activemq::exceptions; using namespace activemq::commands; using namespace activemq::transport; using namespace activemq::transport::discovery; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::net; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -401,7 +403,7 @@ void AbstractDiscoveryAgent::run() { doDiscovery(); } - catch (InterruptedException& ex) + catch (InterruptedException&) { return; } @@ -445,7 +447,7 @@ void AbstractDiscoveryAgent::serviceFailed( { service = impl->discoveredServices.get(event.getServiceName()); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { } } @@ -616,7 +618,7 @@ void AbstractDiscoveryAgent::processLiveService(const std::string& brokerName, { remoteBroker = impl->discoveredServices.get(service); } - catch (NoSuchElementException& ignored) + catch (NoSuchElementException&) { } } @@ -651,7 +653,7 @@ void AbstractDiscoveryAgent::processDeadService(const std::string& service) { remoteBroker = impl->discoveredServices.get(service); } - catch (NoSuchElementException& ignored) + catch (NoSuchElementException&) { } } diff --git a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryAgentRegistry.cpp b/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryAgentRegistry.cpp index 4f107f306..0d9e8b573 100644 --- a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryAgentRegistry.cpp +++ b/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryAgentRegistry.cpp @@ -17,10 +17,13 @@ #include "DiscoveryAgentRegistry.h" +#include #include +#include #include #include +#include using namespace std; using namespace activemq; @@ -30,7 +33,6 @@ using namespace activemq::transport::discovery; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace @@ -60,11 +62,11 @@ DiscoveryAgentFactory* DiscoveryAgentRegistry::findFactory( { if (!this->registry.containsKey(name)) { - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, - "No Matching Factory Registered for format := %s", - name.c_str()); + std::string("No Matching Factory Registered for format := ") + + name); } return this->registry.get(name); @@ -76,17 +78,14 @@ void DiscoveryAgentRegistry::registerFactory(const std::string& name, { if (name == "") { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "DiscoveryAgentFactory name cannot be the empty string"); } if (factory == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Supplied DiscoveryAgentFactory pointer was NULL"); } diff --git a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryAgentRegistry.h b/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryAgentRegistry.h index 0e5016f86..16333ce17 100644 --- a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryAgentRegistry.h +++ b/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryAgentRegistry.h @@ -24,6 +24,7 @@ #include #include +#include namespace activemq { @@ -71,7 +72,7 @@ namespace transport * * @return the Factory registered under the given name. * - * @throws NoSuchElementException if no factory is registered with + * @throws std::runtime_error if no factory is registered with * that name. */ DiscoveryAgentFactory* findFactory(const std::string& name) const; @@ -88,8 +89,8 @@ namespace transport * @param factory * The new Factory to add to the Registry. * - * @throws IllegalArgumentException is name is the empty string. - * @throws NullPointerException if the Factory is Null. + * @throws std::invalid_argument is name is the empty string. + * @throws std::logic_error if the Factory is Null. */ void registerFactory(const std::string& name, DiscoveryAgentFactory* factory); diff --git a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransport.cpp b/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransport.cpp index 0937e730f..ce2b9b289 100644 --- a/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransport.cpp +++ b/activemq-cpp/src/main/activemq/transport/discovery/DiscoveryTransport.cpp @@ -20,23 +20,26 @@ #include #include +#include #include #include -#include +#include +#include #include #include #include #include #include +#include +#include +#include using namespace decaf; using namespace decaf::util; using namespace decaf::util::concurrent; -using namespace decaf::io; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace activemq; using namespace activemq::commands; using namespace activemq::exceptions; @@ -110,9 +113,10 @@ void DiscoveryTransport::start() { if (!this->impl->agent) { - throw IllegalStateException(__FILE__, - __LINE__, - "discoveryAgent not configured"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "discoveryAgent not configured"); } // lets pass into the agent the broker name and connection details @@ -127,25 +131,40 @@ void DiscoveryTransport::stop() { try { - IOException error; - bool hasException = false; + activemq::exceptions::IOException error; + bool hasException = false; try { this->impl->agent->stop(); } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { error = ex; error.setMark(__FILE__, __LINE__); hasException = true; } + catch (activemq::exceptions::ActiveMQException& ex) + { + error = activemq::exceptions::IOException( + static_cast(ex)); + error.setMark(__FILE__, __LINE__); + hasException = true; + } + catch (std::exception& ex) + { + decaf::lang::Exception dex(__FILE__, __LINE__, "%s", ex.what()); + dex.setMark(__FILE__, __LINE__); + error = activemq::exceptions::IOException(dex); + error.setMark(__FILE__, __LINE__); + hasException = true; + } try { TransportFilter::stop(); } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { if (!hasException) { @@ -154,15 +173,36 @@ void DiscoveryTransport::stop() hasException = true; } } + catch (activemq::exceptions::ActiveMQException& ex) + { + if (!hasException) + { + error = activemq::exceptions::IOException( + static_cast(ex)); + error.setMark(__FILE__, __LINE__); + hasException = true; + } + } + catch (std::exception& ex) + { + if (!hasException) + { + decaf::lang::Exception dex(__FILE__, __LINE__, "%s", ex.what()); + dex.setMark(__FILE__, __LINE__); + error = activemq::exceptions::IOException(dex); + error.setMark(__FILE__, __LINE__); + hasException = true; + } + } if (hasException) { throw error; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -172,9 +212,9 @@ void DiscoveryTransport::doClose() { this->impl->next.reset(); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -182,9 +222,10 @@ void DiscoveryTransport::setDiscoveryAgent(std::shared_ptr agent { if (!agent) { - throw NullPointerException(__FILE__, - __LINE__, - "DiscoveryAgent required to be non-null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "DiscoveryAgent required to be non-null"); } this->impl->agent = agent; @@ -248,7 +289,7 @@ void DiscoveryTransport::onServiceRemove(const DiscoveryEvent* event) uris.add(uri); this->impl->next->removeURI(false, uris); } - catch (NoSuchElementException& e) + catch (activemq::exceptions::InterruptedException& e) { } } @@ -264,7 +305,7 @@ void DiscoveryTransport::transportInterrupted() { suspendable->resume(); } - catch (Exception& e) + catch (const std::exception&) { // Failed to Resume } @@ -284,7 +325,7 @@ void DiscoveryTransport::transportResumed() { suspendable->suspend(); } - catch (Exception& e) + catch (const std::exception&) { // Failed to Suspend } diff --git a/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.cpp b/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.cpp index 8edac2a9b..74e577800 100644 --- a/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.cpp +++ b/activemq-cpp/src/main/activemq/transport/discovery/http/HttpDiscoveryAgent.cpp @@ -17,6 +17,8 @@ #include +#include + #include #include @@ -31,8 +33,10 @@ #include #include #include +#include using namespace activemq; +using namespace activemq::exceptions; using namespace activemq::util; using namespace activemq::transport; using namespace activemq::transport::discovery; @@ -41,7 +45,6 @@ using namespace decaf; using namespace decaf::io; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -214,7 +217,7 @@ void HttpDiscoveryAgent::doDiscovery() } while (impl->updateState == SUSPENDED && isStarted()); } } - catch (InterruptedException& e) + catch (InterruptedException&) { return; } diff --git a/activemq-cpp/src/main/activemq/transport/failover/BackupTransportPool.cpp b/activemq-cpp/src/main/activemq/transport/failover/BackupTransportPool.cpp index c884535ff..278ffb7ba 100644 --- a/activemq-cpp/src/main/activemq/transport/failover/BackupTransportPool.cpp +++ b/activemq-cpp/src/main/activemq/transport/failover/BackupTransportPool.cpp @@ -24,8 +24,9 @@ #include #include -#include -#include +#include +#include +#include using namespace activemq; using namespace activemq::threads; @@ -33,9 +34,7 @@ using namespace activemq::exceptions; using namespace activemq::transport; using namespace activemq::transport::failover; using namespace decaf; -using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::net; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -124,37 +123,42 @@ BackupTransportPool::BackupTransportPool( { if (parent == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Parent transport passed is NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Parent transport passed is NULL"); } if (!taskRunner) { - throw NullPointerException(__FILE__, - __LINE__, - "TaskRunner passed is NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "TaskRunner passed is NULL"); } if (!uriPool) { - throw NullPointerException(__FILE__, - __LINE__, - "URIPool passed is NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "URIPool passed is NULL"); } if (!priorityUriPool) { - throw NullPointerException(__FILE__, - __LINE__, - "Piroirty URIPool passed is NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Piroirty URIPool passed is NULL"); } if (!closeTask) { - throw NullPointerException(__FILE__, - __LINE__, - "Close Transport Task passed is NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Close Transport Task passed is NULL"); } this->impl = new BackupTransportPoolImpl(this, parent); @@ -185,37 +189,42 @@ BackupTransportPool::BackupTransportPool( { if (parent == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Parent transport passed is NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Parent transport passed is NULL"); } if (!taskRunner) { - throw NullPointerException(__FILE__, - __LINE__, - "TaskRunner passed is NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "TaskRunner passed is NULL"); } if (!uriPool) { - throw NullPointerException(__FILE__, - __LINE__, - "URIPool passed is NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "URIPool passed is NULL"); } if (!priorityUriPool) { - throw NullPointerException(__FILE__, - __LINE__, - "Piroirty URIPool passed is NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Piroirty URIPool passed is NULL"); } if (!closeTask) { - throw NullPointerException(__FILE__, - __LINE__, - "Close Transport Task passed is NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Close Transport Task passed is NULL"); } this->impl = new BackupTransportPoolImpl(this, parent); @@ -306,9 +315,10 @@ std::shared_ptr BackupTransportPool::getBackup() { if (!isEnabled()) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Backup Pool is not enabled."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Backup Pool is not enabled."); } std::shared_ptr result; @@ -584,7 +594,7 @@ std::shared_ptr BackupTransportPool::createTransport( if (factory == NULL) { - throw new IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "Invalid URI specified, no valid Factory Found."); @@ -595,7 +605,7 @@ std::shared_ptr BackupTransportPool::createTransport( return transport; } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/transport/failover/BackupTransportPool.h b/activemq-cpp/src/main/activemq/transport/failover/BackupTransportPool.h index eede39f77..8d429f3d5 100644 --- a/activemq-cpp/src/main/activemq/transport/failover/BackupTransportPool.h +++ b/activemq-cpp/src/main/activemq/transport/failover/BackupTransportPool.h @@ -27,7 +27,7 @@ #include -#include +#include #include namespace activemq diff --git a/activemq-cpp/src/main/activemq/transport/failover/FailoverTransport.cpp b/activemq-cpp/src/main/activemq/transport/failover/FailoverTransport.cpp index 60fe2bb59..f2d7b3db8 100644 --- a/activemq-cpp/src/main/activemq/transport/failover/FailoverTransport.cpp +++ b/activemq-cpp/src/main/activemq/transport/failover/FailoverTransport.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -31,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -40,8 +42,11 @@ #include #include #include +#include #include #include +#include +#include #include using namespace std; @@ -54,12 +59,10 @@ using namespace activemq::transport; using namespace activemq::transport::failover; using namespace activemq::util; using namespace decaf; -using namespace decaf::io; using namespace decaf::net; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace activemq @@ -396,7 +399,7 @@ namespace transport { sleepMutex.wait(reconnectDelay); } - catch (InterruptedException& e) + catch (InterruptedException&) { Thread::currentThread()->interrupt(); } @@ -437,24 +440,7 @@ namespace transport { if (this->transportListener != NULL) { - std::shared_ptr ioException; - try - { - ioException = std::dynamic_pointer_cast( - this->connectionFailure); - } - AMQ_CATCH_NOTHROW(ClassCastException) - - if (ioException) - { - transportListener->onException( - *this->connectionFailure); - } - else - { - transportListener->onException( - IOException(*this->connectionFailure)); - } + transportListener->onException(*this->connectionFailure); } reconnectMutex.notifyAll(); @@ -615,9 +601,9 @@ void FailoverTransport::reconnect(const decaf::net::URI& uri) reconnect(true); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -773,9 +759,10 @@ void FailoverTransport::oneway(const std::shared_ptr command) // disposed. if (this->impl->closed) { - error.reset(new IOException(__FILE__, - __LINE__, - "Transport disposed.")); + error.reset(new decaf::lang::Exception( + __FILE__, + __LINE__, + "Transport disposed.")); } else if (this->impl->connectionFailure) { @@ -783,7 +770,7 @@ void FailoverTransport::oneway(const std::shared_ptr command) } else if (timedout == true) { - error.reset(new IOException( + error.reset(new decaf::lang::Exception( __FILE__, __LINE__, "Failover timeout of %d ms reached.", @@ -791,16 +778,17 @@ void FailoverTransport::oneway(const std::shared_ptr command) } else if (!this->impl->willReconnect()) { - error.reset(new IOException( + error.reset(new decaf::lang::Exception( __FILE__, __LINE__, "Maximum reconnection attempts exceeded")); } else { - error.reset(new IOException(__FILE__, - __LINE__, - "Unexpected failure.")); + error.reset(new decaf::lang::Exception( + __FILE__, + __LINE__, + "Unexpected failure.")); } break; @@ -846,7 +834,7 @@ void FailoverTransport::oneway(const std::shared_ptr command) this->impl->shutdown = true; } } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { e.setMark(__FILE__, __LINE__); AMQ_LOG_DEBUG("FailoverTransport", @@ -885,7 +873,7 @@ void FailoverTransport::oneway(const std::shared_ptr command) return; } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { e.setMark(__FILE__, __LINE__); handleTransportFailure(e); @@ -893,12 +881,13 @@ void FailoverTransport::oneway(const std::shared_ptr command) } } } - catch (InterruptedException& ex) + catch (InterruptedException&) { Thread::currentThread()->interrupt(); - throw InterruptedIOException(__FILE__, - __LINE__, - "FailoverTransport oneway() interrupted"); + throw InterruptedIOException( + __FILE__, + __LINE__, + std::string("FailoverTransport oneway() interrupted")); } AMQ_CATCHALL_NOTHROW() @@ -906,7 +895,7 @@ void FailoverTransport::oneway(const std::shared_ptr command) { if (error) { - throw IOException(*error); + throw activemq::exceptions::IOException(*error); } } } @@ -916,7 +905,7 @@ std::shared_ptr FailoverTransport::asyncRequest( const std::shared_ptr command AMQCPP_UNUSED, const std::shared_ptr responseCallback AMQCPP_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "FailoverTransport::asyncRequest - Not Supported"); @@ -926,7 +915,7 @@ std::shared_ptr FailoverTransport::asyncRequest( std::shared_ptr FailoverTransport::request( const std::shared_ptr command AMQCPP_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "FailoverTransport::request - Not Supported"); @@ -937,7 +926,7 @@ std::shared_ptr FailoverTransport::request( const std::shared_ptr command AMQCPP_UNUSED, unsigned int timeout AMQCPP_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "FailoverTransport::request - Not Supported"); @@ -981,9 +970,9 @@ void FailoverTransport::start() } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -998,9 +987,9 @@ void FailoverTransport::stop() this->impl->reconnectMutex.notifyAll(); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -1065,9 +1054,9 @@ void FailoverTransport::close() this->impl->taskRunner->shutdown(TimeUnit::SECONDS.toMillis(30)); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -1088,7 +1077,7 @@ void FailoverTransport::reconnect(bool rebalance) { this->impl->taskRunner->wakeup(); } - catch (InterruptedException& ex) + catch (InterruptedException&) { Thread::currentThread()->interrupt(); } @@ -1137,9 +1126,9 @@ void FailoverTransport::restoreTransport( transport->oneway(iter->next()); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -1214,6 +1203,16 @@ void FailoverTransport::handleTransportFailure( } } +//////////////////////////////////////////////////////////////////////////////// +void FailoverTransport::handleTransportFailure( + const activemq::exceptions::IOException& error) +{ + decaf::lang::Exception wrapped(__FILE__, + __LINE__, + error.getMessage().c_str()); + handleTransportFailure(wrapped); +} + //////////////////////////////////////////////////////////////////////////////// void FailoverTransport::handleConnectionControl( const std::shared_ptr control) @@ -1239,7 +1238,7 @@ void FailoverTransport::handleConnectionControl( reconnect(URI(reconnectStr)); } } - catch (Exception& e) + catch (const std::exception&) { } } @@ -1275,7 +1274,7 @@ void FailoverTransport::processNewTransports(bool rebalance, URI uri(str); list.add(uri); } - catch (Exception& e) + catch (const std::exception&) { } } @@ -1286,7 +1285,7 @@ void FailoverTransport::processNewTransports(bool rebalance, { updateURIs(rebalance, list); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { } } @@ -1408,10 +1407,10 @@ bool FailoverTransport::iterate() { AMQ_LOG_ERROR("FailoverTransport", "No URIs available for reconnect"); - failure.reset( - new IOException(__FILE__, - __LINE__, - "No URIs available for reconnect.")); + failure.reset(new decaf::lang::Exception( + __FILE__, + __LINE__, + "No URIs available for reconnect.")); } else { @@ -1557,7 +1556,7 @@ bool FailoverTransport::iterate() { this->impl->sleepMutex.wait(sleepDelay); } - catch (InterruptedException& e) + catch (InterruptedException&) { Thread::currentThread()->interrupt(); } @@ -1605,7 +1604,7 @@ bool FailoverTransport::iterate() { uri = connectList->getURI(); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { break; } @@ -1758,6 +1757,60 @@ bool FailoverTransport::iterate() return false; } + catch (IOException& e) + { + // createTransport() converts many failures to + // activemq::exceptions::IOException, which is not a + // decaf::lang::Exception; treat like Exception& below. + decaf::lang::Exception dex(__FILE__, + __LINE__, + "%s", + e.getMessage().c_str()); + dex.setMark(__FILE__, __LINE__); + AMQ_LOG_DEBUG("FailoverTransport", + "Connection attempt to " + << uri.toString() + << " failed: " << dex.getMessage()); + transportAlreadyStarted = false; + if (transport) + { + if (this->impl->disposedListener != NULL) + { + transport->setTransportListener( + this->impl->disposedListener.get()); + } + + try + { + transport->stop(); + } + catch (...) + { + } + + this->impl->connected.store( + false, + std::memory_order_release); + this->impl->closeTask->add(transport); + this->impl->taskRunner->wakeup(); + transport.reset(); + this->impl->connectingTransport.reset(); + } + + failures.add(uri); + failure.reset(dex.clone()); + + int reconnectAttemptsIo = + this->impl->calculateReconnectAttemptLimit(); + this->impl->markBrokerFailed(uri, + dex.getMessage(), + reconnectAttemptsIo); + int uriAttemptsIo = this->impl->getUriFailureCount(uri); + AMQ_LOG_DEBUG("FailoverTransport", + "URI " << uri.toString() + << " failure count: " + << uriAttemptsIo); + } catch (Exception& e) { e.setMark(__FILE__, __LINE__); @@ -1937,7 +1990,7 @@ std::shared_ptr FailoverTransport::createTransport( if (factory == NULL) { - throw new IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "Invalid URI specified, no valid Factory Found."); @@ -1967,9 +2020,9 @@ std::shared_ptr FailoverTransport::createTransport( return transport; } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -2035,7 +2088,7 @@ void FailoverTransport::processResponse(const std::shared_ptr response object = this->impl->requestMap.remove(response->getCorrelationId()); } - catch (NoSuchElementException& ex) + catch (NoSuchElementException&) { // Not tracking this request in our map, not an error. } @@ -2043,16 +2096,12 @@ void FailoverTransport::processResponse(const std::shared_ptr response if (object) { - try + std::shared_ptr tracked = + std::dynamic_pointer_cast(object); + if (tracked) { - std::shared_ptr tracked = - std::dynamic_pointer_cast(object); - if (tracked) - { - tracked->onResponse(); - } + tracked->onResponse(); } - AMQ_CATCH_NOTHROW(ClassCastException) } } @@ -2316,7 +2365,7 @@ void FailoverTransport::setPriorityURIs( { this->impl->priorityUris->addURI(URI(str)); } - catch (Exception& e) + catch (const std::exception&) { } } diff --git a/activemq-cpp/src/main/activemq/transport/failover/FailoverTransport.h b/activemq-cpp/src/main/activemq/transport/failover/FailoverTransport.h index 6e9c88ca7..56b25367a 100644 --- a/activemq-cpp/src/main/activemq/transport/failover/FailoverTransport.h +++ b/activemq-cpp/src/main/activemq/transport/failover/FailoverTransport.h @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -287,6 +287,13 @@ namespace transport */ void handleTransportFailure(const decaf::lang::Exception& error); + /** + * Same as {@link handleTransportFailure(const + * decaf::lang::Exception&)}, for STL-backed ActiveMQ I/O errors + * raised outside decaf/. + */ + void handleTransportFailure(const exceptions::IOException& error); + /** * Called when the Broker sends a ConnectionControl command which * could signal that this Client needs to reconnect in order to diff --git a/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportFactory.cpp b/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportFactory.cpp index 0dcaa01ae..3ac64ef75 100644 --- a/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportFactory.cpp +++ b/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportFactory.cpp @@ -96,15 +96,17 @@ std::shared_ptr FailoverTransportFactory::doCreateComposite( topLvlProperties.getProperty("maxReconnectAttempts", "20")); transport->setMaxReconnectAttempts(maxReconnectAttempts); - // Default startupMaxReconnectAttempts to 0 (try once on initial - // connect, no retry). After the first successful connection, - // maxReconnectAttempts governs reconnection. + // When startupMaxReconnectAttempts is omitted, use -1 so + // calculateReconnectAttemptLimit() applies maxReconnectAttempts during + // the first-connection phase (matches Java client and unit tests). + // Explicit startupMaxReconnectAttempts=0 still means fail-fast on + // startup. std::string startupMaxStr = topLvlProperties.getProperty("startupMaxReconnectAttempts", ""); int startupMaxReconnectAttempts; if (startupMaxStr.empty()) { - startupMaxReconnectAttempts = 0; + startupMaxReconnectAttempts = -1; } else { diff --git a/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportListener.cpp b/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportListener.cpp index 6a1fd01de..972a94569 100644 --- a/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportListener.cpp +++ b/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportListener.cpp @@ -21,8 +21,10 @@ #include #include +#include #include -#include +#include +#include using namespace activemq; using namespace activemq::exceptions; @@ -31,7 +33,6 @@ using namespace activemq::transport; using namespace activemq::transport::failover; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// FailoverTransportListener::FailoverTransportListener(FailoverTransport* parent) @@ -39,9 +40,10 @@ FailoverTransportListener::FailoverTransportListener(FailoverTransport* parent) { if (this->parent == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Pointer to Parent Transport was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Pointer to Parent Transport was NULL"); } } diff --git a/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp b/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp index 0b79a6521..4ae4cace2 100644 --- a/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp +++ b/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp @@ -20,7 +20,9 @@ #include #include +#include #include +#include using namespace activemq; using namespace activemq::transport; @@ -29,7 +31,6 @@ using namespace decaf; using namespace decaf::net; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// URIPool::URIPool() @@ -115,9 +116,10 @@ URI URIPool::getURI() } } - throw NoSuchElementException(__FILE__, - __LINE__, - "URI Pool is currently empty."); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "URI Pool is currently empty."); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/transport/failover/URIPool.h b/activemq-cpp/src/main/activemq/transport/failover/URIPool.h index 1449bda57..fb5d4c655 100644 --- a/activemq-cpp/src/main/activemq/transport/failover/URIPool.h +++ b/activemq-cpp/src/main/activemq/transport/failover/URIPool.h @@ -22,7 +22,7 @@ #include #include -#include +#include namespace activemq { @@ -110,13 +110,13 @@ namespace transport /** * Fetches the next available URI from the pool, if there are no * more URIs free when this method is called it throws a - * NoSuchElementException. Receiving the exception is not an + * std::runtime_error. Receiving the exception is not an * indication that a URI won't be available in the future, the * caller should react accordingly. * * @return the next free URI in the Pool. * - * @throw NoSuchElementException if there are none free currently. + * @throw std::runtime_error if there are none free currently. */ decaf::net::URI getURI(); diff --git a/activemq-cpp/src/main/activemq/transport/inactivity/InactivityMonitor.cpp b/activemq-cpp/src/main/activemq/transport/inactivity/InactivityMonitor.cpp index 852c7a3e1..bafd76b9e 100644 --- a/activemq-cpp/src/main/activemq/transport/inactivity/InactivityMonitor.cpp +++ b/activemq-cpp/src/main/activemq/transport/inactivity/InactivityMonitor.cpp @@ -28,11 +28,17 @@ #include +#include +#include +#include +#include #include +#include #include #include #include #include +#include using namespace std; using namespace activemq; @@ -43,11 +49,9 @@ using namespace activemq::transport::inactivity; using namespace activemq::exceptions; using namespace activemq::wireformat; using namespace decaf; -using namespace decaf::io; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace activemq @@ -165,7 +169,7 @@ namespace transport bool _e_failed = true; if (this->failed.compare_exchange_strong(_e_failed, false)) { - IOException ex( + ActiveMQException ex( __FILE__, __LINE__, (std::string("Channel was inactive for too long: ") + @@ -225,9 +229,21 @@ namespace transport this->parent->members->keepAliveResponseRequired); this->parent->oneway(info); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { - this->parent->onException(e); + ActiveMQException wrapped(e); + wrapped.setMark(__FILE__, __LINE__); + this->parent->onException(wrapped); + // onException() may destroy 'this' via the transport + // teardown chain. compareAndSet already cleared 'write' + // to false, so return false directly. + return false; + } + catch (decaf::io::IOException& e) + { + ActiveMQException wrapped(e); + wrapped.setMark(__FILE__, __LINE__); + this->parent->onException(wrapped); // onException() may destroy 'this' via the transport // teardown chain. compareAndSet already cleared 'write' // to false, so return false directly. @@ -346,9 +362,9 @@ void InactivityMonitor::afterNextIsStarted() { startMonitorThreads(); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -358,9 +374,9 @@ void InactivityMonitor::beforeNextIsStopped() { stopMonitorThreads(); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -370,9 +386,9 @@ void InactivityMonitor::doClose() { stopMonitorThreads(); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -404,9 +420,17 @@ void InactivityMonitor::onCommand(const std::shared_ptr command) { startMonitorThreads(); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) + { + ActiveMQException wrapped(e); + wrapped.setMark(__FILE__, __LINE__); + onException(wrapped); + } + catch (decaf::io::IOException& e) { - onException(e); + ActiveMQException wrapped(e); + wrapped.setMark(__FILE__, __LINE__); + onException(wrapped); } } } @@ -415,12 +439,29 @@ void InactivityMonitor::onCommand(const std::shared_ptr command) this->members->inRead.store(false); } - catch (Exception& ex) + catch (activemq::exceptions::IOException& ex) { this->members->inRead.store(false); ex.setMark(__FILE__, __LINE__); throw; } + catch (activemq::exceptions::ActiveMQException& ex) + { + this->members->inRead.store(false); + ex.setMark(__FILE__, __LINE__); + throw; + } + catch (std::exception& ex) + { + this->members->inRead.store(false); + decaf::lang::Exception* dex = + dynamic_cast(&ex); + if (dex != nullptr) + { + dex->setMark(__FILE__, __LINE__); + } + throw; + } } //////////////////////////////////////////////////////////////////////////////// @@ -461,19 +502,38 @@ void InactivityMonitor::oneway(const std::shared_ptr command) this->members->commandSent.store(true); this->members->inWrite.store(false); } - catch (Exception& ex) + catch (activemq::exceptions::IOException& ex) + { + this->members->commandSent.store(true); + this->members->inWrite.store(false); + ex.setMark(__FILE__, __LINE__); + throw; + } + catch (activemq::exceptions::ActiveMQException& ex) { this->members->commandSent.store(true); this->members->inWrite.store(false); ex.setMark(__FILE__, __LINE__); throw; } + catch (std::exception& ex) + { + this->members->commandSent.store(true); + this->members->inWrite.store(false); + decaf::lang::Exception* dex = + dynamic_cast(&ex); + if (dex != nullptr) + { + dex->setMark(__FILE__, __LINE__); + } + throw; + } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/transport/inactivity/ReadChecker.cpp b/activemq-cpp/src/main/activemq/transport/inactivity/ReadChecker.cpp index f78addf0a..efaf633b9 100644 --- a/activemq-cpp/src/main/activemq/transport/inactivity/ReadChecker.cpp +++ b/activemq-cpp/src/main/activemq/transport/inactivity/ReadChecker.cpp @@ -19,17 +19,16 @@ #include +#include #include - -#include +#include +#include using namespace activemq; using namespace activemq::transport; using namespace activemq::transport::inactivity; using namespace decaf; using namespace decaf::util; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// ReadChecker::ReadChecker(InactivityMonitor* parent) @@ -39,9 +38,10 @@ ReadChecker::ReadChecker(InactivityMonitor* parent) { if (this->parent == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "ReadChecker created with NULL parent."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "ReadChecker created with NULL parent."); } } diff --git a/activemq-cpp/src/main/activemq/transport/inactivity/WriteChecker.cpp b/activemq-cpp/src/main/activemq/transport/inactivity/WriteChecker.cpp index 1fddf9562..aec0f9ede 100644 --- a/activemq-cpp/src/main/activemq/transport/inactivity/WriteChecker.cpp +++ b/activemq-cpp/src/main/activemq/transport/inactivity/WriteChecker.cpp @@ -19,17 +19,16 @@ #include +#include #include - -#include +#include +#include using namespace activemq; using namespace activemq::transport; using namespace activemq::transport::inactivity; using namespace decaf; using namespace decaf::util; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// WriteChecker::WriteChecker(InactivityMonitor* parent) @@ -39,9 +38,10 @@ WriteChecker::WriteChecker(InactivityMonitor* parent) { if (this->parent == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "WriteChecker created with NULL parent."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "WriteChecker created with NULL parent."); } } diff --git a/activemq-cpp/src/main/activemq/transport/logging/LoggingTransport.cpp b/activemq-cpp/src/main/activemq/transport/logging/LoggingTransport.cpp index db48ef3f4..b36af8d52 100644 --- a/activemq-cpp/src/main/activemq/transport/logging/LoggingTransport.cpp +++ b/activemq-cpp/src/main/activemq/transport/logging/LoggingTransport.cpp @@ -16,6 +16,8 @@ */ #include "LoggingTransport.h" +#include +#include using namespace std; using namespace activemq; @@ -24,7 +26,6 @@ using namespace activemq::transport; using namespace activemq::transport::logging; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// LoggingTransport::LoggingTransport(const std::shared_ptr next) @@ -51,10 +52,10 @@ void LoggingTransport::oneway(const std::shared_ptr command) // Delegate to the base class. TransportFilter::oneway(command); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -70,10 +71,10 @@ std::shared_ptr LoggingTransport::request( return response; } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -91,8 +92,8 @@ std::shared_ptr LoggingTransport::request( return response; } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/transport/mock/InternalCommandListener.cpp b/activemq-cpp/src/main/activemq/transport/mock/InternalCommandListener.cpp index 2e8f5d9bd..764f70365 100644 --- a/activemq-cpp/src/main/activemq/transport/mock/InternalCommandListener.cpp +++ b/activemq-cpp/src/main/activemq/transport/mock/InternalCommandListener.cpp @@ -17,6 +17,7 @@ #include "InternalCommandListener.h" +#include #include using namespace activemq; @@ -24,9 +25,7 @@ using namespace activemq::transport; using namespace activemq::transport::mock; using namespace activemq::exceptions; using namespace activemq::wireformat; -using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// InternalCommandListener::InternalCommandListener() @@ -108,9 +107,9 @@ void InternalCommandListener::run() transport->getNumReceivedMessageBeforeFail()) { transport->fireException( - IOException(__FILE__, - __LINE__, - "Failed to Send Message.")); + ActiveMQException(__FILE__, + __LINE__, + "Failed to Send Message.")); ; } } diff --git a/activemq-cpp/src/main/activemq/transport/mock/MockTransport.cpp b/activemq-cpp/src/main/activemq/transport/mock/MockTransport.cpp old mode 100755 new mode 100644 index 86776e9df..993315971 --- a/activemq-cpp/src/main/activemq/transport/mock/MockTransport.cpp +++ b/activemq-cpp/src/main/activemq/transport/mock/MockTransport.cpp @@ -16,16 +16,17 @@ */ #include +#include +#include #include +#include using namespace activemq; using namespace activemq::transport; using namespace activemq::transport::mock; using namespace activemq::exceptions; using namespace activemq::wireformat; -using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// MockTransport* MockTransport::instance = NULL; @@ -100,11 +101,12 @@ void MockTransport::oneway(const std::shared_ptr command) return; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -152,11 +154,12 @@ std::shared_ptr MockTransport::asyncRequest( __LINE__, "MockTransport::request - no response builder available"); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -195,11 +198,12 @@ std::shared_ptr MockTransport::request( __LINE__, "MockTransport::request - no response builder available"); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -211,11 +215,12 @@ std::shared_ptr MockTransport::request( { return this->request(command); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/transport/mock/MockTransport.h b/activemq-cpp/src/main/activemq/transport/mock/MockTransport.h index 6852bcf11..e7ed8c3b3 100644 --- a/activemq-cpp/src/main/activemq/transport/mock/MockTransport.h +++ b/activemq-cpp/src/main/activemq/transport/mock/MockTransport.h @@ -19,6 +19,7 @@ #define _ACTIVEMQ_TANSPORT_MOCK_MOCKTRANSPORT_H_ #include +#include #include #include #include @@ -385,7 +386,10 @@ namespace transport bool rebalance AMQCPP_UNUSED, const decaf::util::List& uris AMQCPP_UNUSED) { - throw decaf::io::IOException(); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "updateURIs not supported"); } }; diff --git a/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp b/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp index c9fbb3fff..5fd2a6e7b 100644 --- a/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp +++ b/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include using namespace activemq; @@ -37,7 +37,6 @@ using namespace activemq::transport::logging; using namespace activemq::exceptions; using namespace decaf; using namespace decaf::util; -using namespace decaf::io; using namespace decaf::lang; //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.cpp b/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.cpp index f8e3d000f..3d0d47250 100644 --- a/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.cpp +++ b/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.cpp @@ -19,12 +19,13 @@ #include +#include #include #include -#include -#include #include #include +#include +#include using namespace activemq; using namespace activemq::io; @@ -37,7 +38,6 @@ using namespace decaf::net::ssl; using namespace decaf::util; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// SslTransport::SslTransport(const std::shared_ptr next, @@ -72,9 +72,9 @@ Socket* SslTransport::createSocket() SocketFactory* factory = SSLSocketFactory::getDefault(); return factory->createSocket(); } - DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) - DECAF_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -84,17 +84,17 @@ void SslTransport::configureSocket(Socket* socket) { if (socket == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Socket instance passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Socket instance passed was NULL"); } SSLSocket* sslSocket = dynamic_cast(socket); if (sslSocket == NULL) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Socket passed was not an SSLSocket instance."); } @@ -120,8 +120,6 @@ void SslTransport::configureSocket(Socket* socket) TcpTransport::configureSocket(socket); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_RETHROW(SocketException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, SocketException) DECAF_CATCHALL_THROW(SocketException) @@ -144,7 +142,7 @@ void SslTransport::beforeNextIsStarted() this->sslSocket->startHandshake(); } } - DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) - DECAF_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp b/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp index fd4090e6d..4da939e12 100644 --- a/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp +++ b/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp @@ -21,12 +21,11 @@ #include #include -#include -#include #include #include #include #include +#include using namespace std; using namespace activemq; @@ -40,7 +39,6 @@ using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; namespace activemq { @@ -129,9 +127,9 @@ void TcpTransport::beforeNextIsStarted() { connect(); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -146,9 +144,9 @@ void TcpTransport::afterNextIsStopped() impl->socket->close(); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -168,9 +166,9 @@ void TcpTransport::doClose() AMQ_LOG_DEBUG("TcpTransport", "Socket closed"); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -286,9 +284,9 @@ Socket* TcpTransport::createSocket() SocketFactory* factory = SocketFactory::getDefault(); return factory->createSocket(); } - DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) - DECAF_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -319,8 +317,6 @@ void TcpTransport::configureSocket(Socket* socket) socket->setSendBufferSize(soSendBufferSize); } } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_RETHROW(SocketException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, SocketException) DECAF_CATCHALL_THROW(SocketException) diff --git a/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.h b/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.h index a6f444b1a..3f0035b24 100644 --- a/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.h +++ b/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.h @@ -31,6 +31,7 @@ #include #include #include +#include namespace activemq { @@ -143,8 +144,8 @@ namespace transport * The Socket instance to configure using options from the * given Properties. * - * @throw NullPointerException if the Socket instance is null. - * @throw IllegalArgumentException if the socket instance is not + * @throw std::logic_error if the Socket instance is null. + * @throws std::invalid_argument if the socket instance is not * handled by the class. * @throw SocketException if there is an error while setting one of * the Socket options. diff --git a/activemq-cpp/src/main/activemq/util/ActiveMQMessageTransformation.cpp b/activemq-cpp/src/main/activemq/util/ActiveMQMessageTransformation.cpp index ee0863d33..b803822b5 100644 --- a/activemq-cpp/src/main/activemq/util/ActiveMQMessageTransformation.cpp +++ b/activemq-cpp/src/main/activemq/util/ActiveMQMessageTransformation.cpp @@ -41,15 +41,15 @@ #include #include -#include +#include +#include +#include using namespace activemq; using namespace activemq::util; using namespace activemq::core; using namespace activemq::commands; -using namespace decaf::lang::exceptions; - //////////////////////////////////////////////////////////////////////////////// ActiveMQMessageTransformation::ActiveMQMessageTransformation() { @@ -67,17 +67,13 @@ bool ActiveMQMessageTransformation::transformDestination( { if (destination == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Provided source cms::Destination pointer was NULL"); } if (amqDestination == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Provided target ActiveMQDestination pointer was NULL"); } @@ -124,7 +120,7 @@ bool ActiveMQMessageTransformation::transformMessage( { if (message == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Provided source cms::Message pointer was NULL"); @@ -132,9 +128,7 @@ bool ActiveMQMessageTransformation::transformMessage( if (amqMessage == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Provided target commands::Message pointer was NULL"); } @@ -332,7 +326,7 @@ void ActiveMQMessageTransformation::copyProperties( { if (fromMessage == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Provided source cms::Message pointer was NULL"); @@ -340,9 +334,7 @@ void ActiveMQMessageTransformation::copyProperties( if (toMessage == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Provided destination cms::Message pointer was NULL"); } diff --git a/activemq-cpp/src/main/activemq/util/AdvisorySupport.cpp b/activemq-cpp/src/main/activemq/util/AdvisorySupport.cpp index 9046f16f6..09610547d 100644 --- a/activemq-cpp/src/main/activemq/util/AdvisorySupport.cpp +++ b/activemq-cpp/src/main/activemq/util/AdvisorySupport.cpp @@ -22,15 +22,15 @@ #include #include -#include +#include #include +#include +#include using namespace activemq; using namespace activemq::util; using namespace activemq::commands; using namespace decaf::util; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// const std::string AdvisorySupport::ADVISORY_TOPIC_PREFIX = "ActiveMQ.Advisory."; @@ -222,7 +222,7 @@ ActiveMQDestination* AdvisorySupport::getConsumerAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -265,7 +265,7 @@ ActiveMQDestination* AdvisorySupport::getProducerAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -308,7 +308,7 @@ ActiveMQDestination* AdvisorySupport::getExpiredMessageTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -348,7 +348,7 @@ ActiveMQDestination* AdvisorySupport::getExpiredTopicMessageAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -384,7 +384,7 @@ ActiveMQDestination* AdvisorySupport::getExpiredQueueMessageAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -420,7 +420,7 @@ ActiveMQDestination* AdvisorySupport::getNoConsumersAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -459,7 +459,7 @@ ActiveMQDestination* AdvisorySupport::getNoTopicConsumersAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -495,7 +495,7 @@ ActiveMQDestination* AdvisorySupport::getNoQueueConsumersAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -531,7 +531,7 @@ ActiveMQDestination* AdvisorySupport::getSlowConsumerAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -569,7 +569,7 @@ ActiveMQDestination* AdvisorySupport::getFastProducerAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -607,7 +607,7 @@ ActiveMQDestination* AdvisorySupport::getMessageDiscardedAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -645,7 +645,7 @@ ActiveMQDestination* AdvisorySupport::getMessageDeliveredAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -683,7 +683,7 @@ ActiveMQDestination* AdvisorySupport::getMessageConsumedAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -721,7 +721,7 @@ ActiveMQDestination* AdvisorySupport::getMessageDLQdAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -770,7 +770,7 @@ ActiveMQDestination* AdvisorySupport::getFullAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -808,7 +808,7 @@ ActiveMQDestination* AdvisorySupport::getDestinationAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -825,11 +825,10 @@ ActiveMQDestination* AdvisorySupport::getDestinationAdvisoryTopic( case cms::Destination::TEMPORARY_TOPIC: return getTempTopicAdvisoryTopic(); default: - throw new IllegalArgumentException( - __FILE__, - __LINE__, - "Unknown destination type: %d", - (int)destination->getDestinationType()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Unknown destination type: " + + std::to_string((int)destination->getDestinationType())); } } @@ -858,7 +857,7 @@ bool AdvisorySupport::isDestinationAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -912,7 +911,7 @@ bool AdvisorySupport::isTempDestinationAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -963,7 +962,7 @@ bool AdvisorySupport::isAdvisoryTopic(const ActiveMQDestination* destination) { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1016,7 +1015,7 @@ bool AdvisorySupport::isConnectionAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1067,7 +1066,7 @@ bool AdvisorySupport::isProducerAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1119,7 +1118,7 @@ bool AdvisorySupport::isConsumerAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1171,7 +1170,7 @@ bool AdvisorySupport::isSlowConsumerAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1222,7 +1221,7 @@ bool AdvisorySupport::isFastProducerAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1273,7 +1272,7 @@ bool AdvisorySupport::isMessageConsumedAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1326,7 +1325,7 @@ bool AdvisorySupport::isMasterBrokerAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1377,7 +1376,7 @@ bool AdvisorySupport::isMessageDeliveredAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1430,7 +1429,7 @@ bool AdvisorySupport::isMessageDiscardedAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1483,7 +1482,7 @@ bool AdvisorySupport::isMessageDLQdAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1532,7 +1531,7 @@ bool AdvisorySupport::isFullAdvisoryTopic(const ActiveMQDestination* destination { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); @@ -1583,7 +1582,7 @@ bool AdvisorySupport::isNetworkBridgeAdvisoryTopic( { if (destination == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The passed ActiveMQDestination cannot be NULL"); diff --git a/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.cpp b/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.cpp index b73408a34..710db9ce7 100644 --- a/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.cpp +++ b/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.cpp @@ -17,13 +17,15 @@ #include "CMSExceptionSupport.h" +#include + #include using namespace std; using namespace cms; using namespace activemq; using namespace activemq::util; -using namespace decaf; +using namespace activemq::exceptions; using namespace decaf::lang; //////////////////////////////////////////////////////////////////////////////// @@ -59,6 +61,32 @@ CMSException CMSExceptionSupport::create(const Exception& cause) return exception; } +//////////////////////////////////////////////////////////////////////////////// +CMSException CMSExceptionSupport::create(const std::exception& cause) +{ + std::string msg = cause.what(); + + if (msg.length() == 0) + { + msg = typeid(cause).name(); + } + + return CMSException(msg, NULL); +} + +//////////////////////////////////////////////////////////////////////////////// +CMSException CMSExceptionSupport::create(const IOException& cause) +{ + std::string msg = cause.getMessage(); + + if (msg.length() == 0) + { + msg = typeid(cause).name(); + } + + return CMSException(msg, NULL); +} + //////////////////////////////////////////////////////////////////////////////// MessageEOFException CMSExceptionSupport::createMessageEOFException( const Exception& cause) @@ -75,6 +103,20 @@ MessageEOFException CMSExceptionSupport::createMessageEOFException( return exception; } +//////////////////////////////////////////////////////////////////////////////// +MessageEOFException CMSExceptionSupport::createMessageEOFException( + const EOFException& cause) +{ + std::string msg = cause.getMessage(); + + if (msg.length() == 0) + { + msg = typeid(cause).name(); + } + + return MessageEOFException(msg, NULL); +} + //////////////////////////////////////////////////////////////////////////////// MessageFormatException CMSExceptionSupport::createMessageFormatException( const Exception& cause) @@ -90,3 +132,31 @@ MessageFormatException CMSExceptionSupport::createMessageFormatException( return exception; } + +//////////////////////////////////////////////////////////////////////////////// +MessageFormatException CMSExceptionSupport::createMessageFormatException( + const IOException& cause) +{ + std::string msg = cause.getMessage(); + + if (msg.length() == 0) + { + msg = typeid(cause).name(); + } + + return MessageFormatException(msg, NULL); +} + +//////////////////////////////////////////////////////////////////////////////// +MessageFormatException CMSExceptionSupport::createMessageFormatException( + const std::exception& cause) +{ + std::string msg = cause.what(); + + if (msg.length() == 0) + { + msg = typeid(cause).name(); + } + + return MessageFormatException(msg, NULL); +} diff --git a/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h b/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h index fda4dfc1e..4990a6f83 100644 --- a/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h +++ b/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h @@ -36,8 +36,15 @@ #include #include +#include +#include + +#include +#include +#include #include +#include #include namespace activemq @@ -57,17 +64,155 @@ namespace util const decaf::lang::Exception& cause); static cms::CMSException create(const decaf::lang::Exception& cause); + static cms::CMSException create(const exceptions::IOException& cause); + static cms::CMSException create(const std::exception& cause); static cms::MessageEOFException createMessageEOFException( const decaf::lang::Exception& cause); + static cms::MessageEOFException createMessageEOFException( + const exceptions::EOFException& cause); + static cms::MessageFormatException createMessageFormatException( const decaf::lang::Exception& cause); + + static cms::MessageFormatException createMessageFormatException( + const exceptions::IOException& cause); + + static cms::MessageFormatException createMessageFormatException( + const std::exception& cause); }; } // namespace util } // namespace activemq +/** + * Map AMQ STL-backed property-layer failures to CMS MessageFormatException. + * Replaces catch (std::logic_error&) for OpenWire property interceptors. + */ +#define AMQ_CATCH_PROPERTY_LAYER_AS_MESSAGE_FORMAT() \ + catch (::activemq::exceptions::IllegalStateException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::InvalidStateException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::CloneNotSupportedException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::NullPointerException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::UnsupportedOperationException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::IllegalMonitorStateException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::TypeMismatchException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::OutOfRangeException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::InvalidArgumentException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::InterruptedException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::RuntimeException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::ConcurrentModificationException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::NoSuchElementException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } + +/** + * Map decaf stream exceptions from message body read/write to CMS types + * (MessageEOFException, MessageFormatException, or CMSException). + */ +#define AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() \ + catch (::activemq::exceptions::EOFException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport::createMessageEOFException( \ + ex); \ + } \ + catch (::activemq::exceptions::IOException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::decaf::io::EOFException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw ::activemq::util::CMSExceptionSupport::createMessageEOFException( \ + ex); \ + } \ + catch (::decaf::io::IOException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw ::activemq::util::CMSExceptionSupport:: \ + createMessageFormatException(ex); \ + } \ + catch (::activemq::exceptions::ActiveMQException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw ::activemq::util::CMSExceptionSupport::create(ex); \ + } \ + catch (::decaf::lang::Exception & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw ::activemq::util::CMSExceptionSupport::create(ex); \ + } \ + catch (std::exception & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport::create(ex); \ + } + +/** + * Single IOException from a nested decaf stream operation -> CMSException. + */ +#define AMQ_CATCH_DECAF_IOSTREAM_IOEXCEPTION_TO_CMS() \ + catch (::activemq::exceptions::IOException & ex) \ + { \ + throw ::activemq::util::CMSExceptionSupport::create(ex); \ + } \ + catch (::decaf::io::IOException & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + throw ::activemq::util::CMSExceptionSupport::create(ex); \ + } + /** * Macro for catching an exception of one type and then re-throwing * as a Basic CMSException, good for cases where the method isn't specific @@ -286,15 +431,12 @@ namespace util ex.setMark(__FILE__, __LINE__); \ throw ex.convertToCMSException(); \ } \ - catch (decaf::lang::Exception & ex) \ - { \ - ex.setMark(__FILE__, __LINE__); \ - activemq::exceptions::ActiveMQException amqEx(ex); \ - throw amqEx.convertToCMSException(); \ - } \ catch (std::exception & ex) \ { \ - throw cms::CMSException(ex.what(), NULL); \ + decaf::lang::Exception cause(__FILE__, __LINE__, "%s", ex.what()); \ + cause.setMark(__FILE__, __LINE__); \ + activemq::exceptions::ActiveMQException amqEx(cause); \ + throw amqEx.convertToCMSException(); \ } \ catch (...) \ { \ diff --git a/activemq-cpp/src/main/activemq/util/IdGenerator.cpp b/activemq-cpp/src/main/activemq/util/IdGenerator.cpp index 94df64590..64909e94e 100644 --- a/activemq-cpp/src/main/activemq/util/IdGenerator.cpp +++ b/activemq-cpp/src/main/activemq/util/IdGenerator.cpp @@ -24,14 +24,14 @@ #include #include +#include #include -#include +#include using namespace activemq; using namespace activemq::util; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::net; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -122,9 +122,10 @@ std::string IdGenerator::generateId() const if (IdGenerator::kernel == NULL) { - throw RuntimeException(__FILE__, - __LINE__, - "Library is not initialized."); + throw activemq::exceptions::RuntimeException( + __FILE__, + __LINE__, + "Library is not initialized."); } synchronized(&(IdGenerator::kernel->mutex)) diff --git a/activemq-cpp/src/main/activemq/util/MarshallingSupport.cpp b/activemq-cpp/src/main/activemq/util/MarshallingSupport.cpp index 171de73a4..47d39b581 100644 --- a/activemq-cpp/src/main/activemq/util/MarshallingSupport.cpp +++ b/activemq-cpp/src/main/activemq/util/MarshallingSupport.cpp @@ -24,8 +24,8 @@ using namespace activemq; using namespace activemq::util; +using activemq::exceptions::UTFDataFormatException; using namespace decaf; -using namespace decaf::io; using namespace decaf::lang; using namespace std; @@ -56,9 +56,9 @@ void MarshallingSupport::writeString(decaf::io::DataOutputStream& dataOut, MarshallingSupport::writeString32(dataOut, value); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -71,10 +71,11 @@ void MarshallingSupport::writeString16(decaf::io::DataOutputStream& dataOut, if (strSize > Short::MAX_VALUE) { - throw IOException(__FILE__, - __LINE__, - "String size exceeds Short::MAX_VALUE and cannot " - "be sent via Openwire."); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "String size exceeds Short::MAX_VALUE and cannot " + "be sent via Openwire."); } dataOut.writeShort((short)strSize); @@ -83,9 +84,9 @@ void MarshallingSupport::writeString16(decaf::io::DataOutputStream& dataOut, dataOut.write((unsigned char*)value.c_str(), strSize, 0, strSize); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -98,10 +99,11 @@ void MarshallingSupport::writeString32(decaf::io::DataOutputStream& dataOut, if (strSize > Integer::MAX_VALUE) { - throw IOException(__FILE__, - __LINE__, - "String size exceeds Integer::MAX_VALUE and " - "cannot be sent via Openwire."); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "String size exceeds Integer::MAX_VALUE and " + "cannot be sent via Openwire."); } dataOut.writeInt(strSize); @@ -110,9 +112,9 @@ void MarshallingSupport::writeString32(decaf::io::DataOutputStream& dataOut, dataOut.write((unsigned char*)value.c_str(), strSize, 0, strSize); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -129,9 +131,9 @@ std::string MarshallingSupport::readString16(decaf::io::DataInputStream& dataIn) } return ""; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -148,9 +150,9 @@ std::string MarshallingSupport::readString32(decaf::io::DataInputStream& dataIn) } return ""; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -235,9 +237,10 @@ std::string MarshallingSupport::asciiToModifiedUtf8( return ""; } } - AMQ_CATCH_RETHROW(decaf::io::UTFDataFormatException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, decaf::io::UTFDataFormatException) - AMQ_CATCHALL_THROW(decaf::io::UTFDataFormatException) + AMQ_CATCH_RETHROW(activemq::exceptions::UTFDataFormatException) + AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, + activemq::exceptions::UTFDataFormatException) + AMQ_CATCHALL_THROW(activemq::exceptions::UTFDataFormatException) } //////////////////////////////////////////////////////////////////////////////// @@ -348,7 +351,8 @@ std::string MarshallingSupport::modifiedUtf8ToAscii( return std::string((char*)(&result[0]), index); } - AMQ_CATCH_RETHROW(decaf::io::UTFDataFormatException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, decaf::io::UTFDataFormatException) - AMQ_CATCHALL_THROW(decaf::io::UTFDataFormatException) + AMQ_CATCH_RETHROW(activemq::exceptions::UTFDataFormatException) + AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, + activemq::exceptions::UTFDataFormatException) + AMQ_CATCHALL_THROW(activemq::exceptions::UTFDataFormatException) } diff --git a/activemq-cpp/src/main/activemq/util/MarshallingSupport.h b/activemq-cpp/src/main/activemq/util/MarshallingSupport.h index 18f002c1f..5daa265c3 100644 --- a/activemq-cpp/src/main/activemq/util/MarshallingSupport.h +++ b/activemq-cpp/src/main/activemq/util/MarshallingSupport.h @@ -20,8 +20,8 @@ #include -#include -#include +#include +#include #include #include @@ -138,8 +138,8 @@ namespace util * @return a string containing the Modified UTF-8 encoded form of the * provided string. * - * @throws UTFDataFormatException if the length of the encoded string - * would exceed the size of an signed integer. + * @throws activemq::exceptions::UTFDataFormatException if the length of + * the encoded string would exceed the size of an signed integer. */ static std::string asciiToModifiedUtf8(const std::string& asciiString); @@ -155,9 +155,9 @@ namespace util * * @return the ASCII encoded version of the provided string. * - * @throws UTFDataFormatException if the provided string contains - * invalid data or the character values encoded in the string exceed - * ASCII value 255. + * @throws activemq::exceptions::UTFDataFormatException if the provided + * string contains invalid data or the character values encoded in the + * string exceed ASCII value 255. */ static std::string modifiedUtf8ToAscii( const std::string modifiedUtf8String); diff --git a/activemq-cpp/src/main/activemq/util/PrimitiveList.cpp b/activemq-cpp/src/main/activemq/util/PrimitiveList.cpp index 985fb60a2..5cf1819a4 100644 --- a/activemq-cpp/src/main/activemq/util/PrimitiveList.cpp +++ b/activemq-cpp/src/main/activemq/util/PrimitiveList.cpp @@ -22,7 +22,6 @@ using namespace activemq; using namespace activemq::util; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace std; diff --git a/activemq-cpp/src/main/activemq/util/PrimitiveList.h b/activemq-cpp/src/main/activemq/util/PrimitiveList.h index f562c4271..61934a325 100644 --- a/activemq-cpp/src/main/activemq/util/PrimitiveList.h +++ b/activemq-cpp/src/main/activemq/util/PrimitiveList.h @@ -20,10 +20,9 @@ #include #include -#include -#include #include #include +#include #include #include @@ -71,8 +70,8 @@ namespace util * Gets the Boolean value at the specified index. * @param index - index to get value from * @return value contained at the given index - * @throw IndexOutOfBoundsException if index is > size() - * @throw UnsupportedOperationException if the type at index is not of + * @throw std::out_of_range if index is > size() + * @throws std::logic_error if the type at index is not of * the type that this method is to return or can convert to. */ virtual bool getBool(int index) const; @@ -84,7 +83,7 @@ namespace util * than the size of the list. * @param index - location to set in the list * @param value - the new value to assign to the element at index - * @throw IndexOutOfBoundsException if index > size(). + * @throw std::out_of_range if index > size(). */ virtual void setBool(int index, bool value); @@ -92,8 +91,8 @@ namespace util * Gets the Byte value at the specified index. * @param index - index to get value from * @return value contained at the given index - * @throw IndexOutOfBoundsException if index is > size() - * @throw UnsupportedOperationException if the type at index is not of + * @throw std::out_of_range if index is > size() + * @throws std::logic_error if the type at index is not of * the type that this method is to return or can convert to. */ virtual unsigned char getByte(int index) const; @@ -105,7 +104,7 @@ namespace util * than the size of the list. * @param index - location to set in the list * @param value - the new value to assign to the element at index - * @throw IndexOutOfBoundsException if index > size(). + * @throw std::out_of_range if index > size(). */ virtual void setByte(int index, unsigned char value); @@ -113,8 +112,8 @@ namespace util * Gets the Character value at the specified index. * @param index - index to get value from * @return value contained at the given index - * @throw IndexOutOfBoundsException if index is > size() - * @throw UnsupportedOperationException if the type at index is not of + * @throw std::out_of_range if index is > size() + * @throws std::logic_error if the type at index is not of * the type that this method is to return or can convert to. */ virtual char getChar(int index) const; @@ -126,7 +125,7 @@ namespace util * than the size of the list. * @param index - location to set in the list * @param value - the new value to assign to the element at index - * @throw IndexOutOfBoundsException if index > size(). + * @throw std::out_of_range if index > size(). */ virtual void setChar(int index, char value); @@ -134,8 +133,8 @@ namespace util * Gets the Short value at the specified index. * @param index - index to get value from * @return value contained at the given index - * @throw IndexOutOfBoundsException if index is > size() - * @throw UnsupportedOperationException if the type at index is not of + * @throw std::out_of_range if index is > size() + * @throws std::logic_error if the type at index is not of * the type that this method is to return or can convert to. */ virtual short getShort(int index) const; @@ -147,7 +146,7 @@ namespace util * than the size of the list. * @param index - location to set in the list * @param value - the new value to assign to the element at index - * @throw IndexOutOfBoundsException if index > size(). + * @throw std::out_of_range if index > size(). */ virtual void setShort(int index, short value); @@ -155,8 +154,8 @@ namespace util * Gets the Integer value at the specified index. * @param index - index to get value from * @return value contained at the given index - * @throw IndexOutOfBoundsException if index is > size() - * @throw UnsupportedOperationException if the type at index is not of + * @throw std::out_of_range if index is > size() + * @throws std::logic_error if the type at index is not of * the type that this method is to return or can convert to. */ virtual int getInt(int index) const; @@ -168,7 +167,7 @@ namespace util * than the size of the list. * @param index - location to set in the list * @param value - the new value to assign to the element at index - * @throw IndexOutOfBoundsException if index > size(). + * @throw std::out_of_range if index > size(). */ virtual void setInt(int index, int value); @@ -176,8 +175,8 @@ namespace util * Gets the Long value at the specified index. * @param index - index to get value from * @return value contained at the given index - * @throw IndexOutOfBoundsException if index is > size() - * @throw UnsupportedOperationException if the type at index is not of + * @throw std::out_of_range if index is > size() + * @throws std::logic_error if the type at index is not of * the type that this method is to return or can convert to. */ virtual long long getLong(int index) const; @@ -189,7 +188,7 @@ namespace util * than the size of the list. * @param index - location to set in the list * @param value - the new value to assign to the element at index - * @throw IndexOutOfBoundsException if index > size(). + * @throw std::out_of_range if index > size(). */ virtual void setLong(int index, long long value); @@ -197,8 +196,8 @@ namespace util * Gets the Float value at the specified index. * @param index - index to get value from * @return value contained at the given index - * @throw IndexOutOfBoundsException if index is > size() - * @throw UnsupportedOperationException if the type at index is not of + * @throw std::out_of_range if index is > size() + * @throws std::logic_error if the type at index is not of * the type that this method is to return or can convert to. */ virtual float getFloat(int index) const; @@ -210,7 +209,7 @@ namespace util * than the size of the list. * @param index - location to set in the list * @param value - the new value to assign to the element at index - * @throw IndexOutOfBoundsException if index > size(). + * @throw std::out_of_range if index > size(). */ virtual void setFloat(int index, float value); @@ -218,8 +217,8 @@ namespace util * Gets the Double value at the specified index. * @param index - index to get value from * @return value contained at the given index - * @throw IndexOutOfBoundsException if index is > size() - * @throw UnsupportedOperationException if the type at index is not of + * @throw std::out_of_range if index is > size() + * @throws std::logic_error if the type at index is not of * the type that this method is to return or can convert to. */ virtual double getDouble(int index) const; @@ -231,7 +230,7 @@ namespace util * than the size of the list. * @param index - location to set in the list * @param value - the new value to assign to the element at index - * @throw IndexOutOfBoundsException if index > size(). + * @throw std::out_of_range if index > size(). */ virtual void setDouble(int index, double value); @@ -239,8 +238,8 @@ namespace util * Gets the String value at the specified index. * @param index - index to get value from * @return value contained at the given index - * @throw IndexOutOfBoundsException if index is > size() - * @throw UnsupportedOperationException if the type at index is not of + * @throw std::out_of_range if index is > size() + * @throws std::logic_error if the type at index is not of * the type that this method is to return or can convert to. */ virtual std::string getString(int index) const; @@ -252,7 +251,7 @@ namespace util * than the size of the list. * @param index - location to set in the list * @param value - the new value to assign to the element at index - * @throw IndexOutOfBoundsException if index > size(). + * @throw std::out_of_range if index > size(). */ virtual void setString(int index, const std::string& value); @@ -260,8 +259,8 @@ namespace util * Gets the Byte Array value at the specified index. * @param index - index to get value from * @return value contained at the given index - * @throw IndexOutOfBoundsException if index is > size() - * @throw UnsupportedOperationException if the type at index is not of + * @throw std::out_of_range if index is > size() + * @throws std::logic_error if the type at index is not of * the type that this method is to return or can convert to. */ virtual std::vector getByteArray(int index) const; @@ -273,7 +272,7 @@ namespace util * than the size of the list. * @param index - location to set in the list * @param value - the new value to assign to the element at index - * @throw IndexOutOfBoundsException if index > size(). + * @throw std::out_of_range if index > size(). */ virtual void setByteArray(int index, const std::vector& value); diff --git a/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp b/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp index 9e371786c..64ef1d706 100644 --- a/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp +++ b/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp @@ -27,7 +27,6 @@ using namespace activemq; using namespace activemq::util; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::lang; using namespace std; diff --git a/activemq-cpp/src/main/activemq/util/PrimitiveMap.h b/activemq-cpp/src/main/activemq/util/PrimitiveMap.h index 323472c90..0560d1e2e 100644 --- a/activemq-cpp/src/main/activemq/util/PrimitiveMap.h +++ b/activemq-cpp/src/main/activemq/util/PrimitiveMap.h @@ -22,8 +22,8 @@ #include #include #include -#include #include +#include #include #include @@ -77,7 +77,7 @@ namespace util /** * @return the numeric type value for the given key if it exists. - * @throws NoSuchElementException if the key is not present in the map. + * @throws std::runtime_error if the key is not present in the map. */ virtual PrimitiveValueNode::PrimitiveType getValueType( const std::string& key) const; @@ -85,11 +85,11 @@ namespace util /** * Gets the Boolean value at the given key, if the key is not * in the map or cannot be returned as the requested value then - * an exception of type NoSuchElementException is thrown. + * an exception of type std::runtime_error is thrown. * * @param key - the location to return the value from. * @return the value at key in the type requested. - * @throw NoSuchElementException if key is not in the map. + * @throw std::runtime_error if key is not in the map. * @throw UnSupportedOperationException if the value cannot be converted * to the type this method returns */ @@ -106,11 +106,11 @@ namespace util /** * Gets the Byte value at the given key, if the key is not * in the map or cannot be returned as the requested value then - * an exception of type NoSuchElementException is thrown. + * an exception of type std::runtime_error is thrown. * * @param key - the location to return the value from. * @return the value at key in the type requested. - * @throw NoSuchElementException if key is not in the map. + * @throw std::runtime_error if key is not in the map. * @throw UnSupportedOperationException if the value cannot be converted * to the type this method returns */ @@ -127,11 +127,11 @@ namespace util /** * Gets the Character value at the given key, if the key is not * in the map or cannot be returned as the requested value then - * an exception of type NoSuchElementException is thrown. + * an exception of type std::runtime_error is thrown. * * @param key - the location to return the value from. * @return the value at key in the type requested. - * @throw NoSuchElementException if key is not in the map. + * @throw std::runtime_error if key is not in the map. * @throw UnSupportedOperationException if the value cannot be converted * to the type this method returns */ @@ -148,11 +148,11 @@ namespace util /** * Gets the Short value at the given key, if the key is not * in the map or cannot be returned as the requested value then - * an exception of type NoSuchElementException is thrown. + * an exception of type std::runtime_error is thrown. * * @param key - the location to return the value from. * @return the value at key in the type requested. - * @throw NoSuchElementException if key is not in the map. + * @throw std::runtime_error if key is not in the map. * @throw UnSupportedOperationException if the value cannot be converted * to the type this method returns */ @@ -169,11 +169,11 @@ namespace util /** * Gets the Integer value at the given key, if the key is not * in the map or cannot be returned as the requested value then - * an exception of type NoSuchElementException is thrown. + * an exception of type std::runtime_error is thrown. * * @param key - the location to return the value from. * @return the value at key in the type requested. - * @throw NoSuchElementException if key is not in the map. + * @throw std::runtime_error if key is not in the map. * @throw UnSupportedOperationException if the value cannot be converted * to the type this method returns */ @@ -190,11 +190,11 @@ namespace util /** * Gets the Long value at the given key, if the key is not * in the map or cannot be returned as the requested value then - * an exception of type NoSuchElementException is thrown. + * an exception of type std::runtime_error is thrown. * * @param key - the location to return the value from. * @return the value at key in the type requested. - * @throw NoSuchElementException if key is not in the map. + * @throw std::runtime_error if key is not in the map. * @throw UnSupportedOperationException if the value cannot be converted * to the type this method returns */ @@ -211,11 +211,11 @@ namespace util /** * Gets the Float value at the given key, if the key is not * in the map or cannot be returned as the requested value then - * an exception of type NoSuchElementException is thrown. + * an exception of type std::runtime_error is thrown. * * @param key - the location to return the value from. * @return the value at key in the type requested. - * @throw NoSuchElementException if key is not in the map. + * @throw std::runtime_error if key is not in the map. * @throw UnSupportedOperationException if the value cannot be converted * to the type this method returns */ @@ -232,11 +232,11 @@ namespace util /** * Gets the Double value at the given key, if the key is not * in the map or cannot be returned as the requested value then - * an exception of type NoSuchElementException is thrown. + * an exception of type std::runtime_error is thrown. * * @param key - the location to return the value from. * @return the value at key in the type requested. - * @throw NoSuchElementException if key is not in the map. + * @throw std::runtime_error if key is not in the map. * @throw UnSupportedOperationException if the value cannot be converted * to the type this method returns */ @@ -253,11 +253,11 @@ namespace util /** * Gets the String value at the given key, if the key is not * in the map or cannot be returned as the requested value then - * an exception of type NoSuchElementException is thrown. + * an exception of type std::runtime_error is thrown. * * @param key - the location to return the value from. * @return the value at key in the type requested. - * @throw NoSuchElementException if key is not in the map. + * @throw std::runtime_error if key is not in the map. * @throw UnSupportedOperationException if the value cannot be converted * to the type this method returns */ @@ -275,11 +275,11 @@ namespace util /** * Gets the Byte Array value at the given key, if the key is not * in the map or cannot be returned as the requested value then - * an exception of type NoSuchElementException is thrown. + * an exception of type std::runtime_error is thrown. * * @param key - the location to return the value from. * @return the value at key in the type requested. - * @throw NoSuchElementException if key is not in the map. + * @throw std::runtime_error if key is not in the map. * @throw UnSupportedOperationException if the value cannot be converted * to the type this method returns */ diff --git a/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.cpp b/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.cpp index fed1c4e0d..4cf93e60b 100644 --- a/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.cpp +++ b/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.cpp @@ -17,6 +17,7 @@ #include "PrimitiveValueConverter.h" +#include #include #include #include @@ -25,6 +26,9 @@ #include #include #include +#include +#include +#include using namespace activemq; using namespace activemq::util; @@ -45,12 +49,12 @@ bool PrimitiveValueConverter::convert( { return decaf::lang::Boolean::parseBoolean(value.getString()); } - catch (decaf::lang::Exception& ex) + catch (std::exception& ex) { } } default: - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Unsupported Type Conversion"); @@ -73,12 +77,12 @@ unsigned char PrimitiveValueConverter::convert( { return decaf::lang::Byte::parseByte(value.getString()); } - catch (decaf::lang::Exception& ex) + catch (std::exception& ex) { } } default: - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Unsupported Type Conversion"); @@ -101,12 +105,12 @@ char PrimitiveValueConverter::convert( { return (char)decaf::lang::Byte::parseByte(value.getString()); } - catch (decaf::lang::Exception& ex) + catch (std::exception& ex) { } } default: - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Unsupported Type Conversion"); @@ -131,12 +135,12 @@ short PrimitiveValueConverter::convert( { return decaf::lang::Short::parseShort(value.getString()); } - catch (decaf::lang::Exception& ex) + catch (std::exception& ex) { } } default: - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Unsupported Type Conversion"); @@ -162,12 +166,12 @@ int PrimitiveValueConverter::convert(const PrimitiveValueNode& value) const { return decaf::lang::Integer::parseInt(value.getString()); } - catch (decaf::lang::Exception& ex) + catch (std::exception& ex) { } } default: - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Unsupported Type Conversion"); @@ -196,12 +200,12 @@ long long PrimitiveValueConverter::convert( { return decaf::lang::Long::parseLong(value.getString()); } - catch (decaf::lang::Exception& ex) + catch (std::exception& ex) { } } default: - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Unsupported Type Conversion"); @@ -224,12 +228,12 @@ float PrimitiveValueConverter::convert( { return decaf::lang::Float::parseFloat(value.getString()); } - catch (decaf::lang::Exception& ex) + catch (std::exception& ex) { } } default: - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Unsupported Type Conversion"); @@ -254,12 +258,12 @@ double PrimitiveValueConverter::convert( { return decaf::lang::Double::parseDouble(value.getString()); } - catch (decaf::lang::Exception& ex) + catch (std::exception& ex) { } } default: - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Unsupported Type Conversion"); @@ -295,7 +299,7 @@ std::string PrimitiveValueConverter::convert( case PrimitiveValueNode::BIG_STRING_TYPE: return value.getString(); default: - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Unsupported Type Conversion"); @@ -313,7 +317,7 @@ PrimitiveValueConverter::convert>( case PrimitiveValueNode::BYTE_ARRAY_TYPE: return value.getByteArray(); default: - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Unsupported Type Conversion"); diff --git a/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.h b/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.h index 5ce03812f..1f85b8cd6 100644 --- a/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.h +++ b/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.h @@ -20,8 +20,9 @@ #include +#include #include -#include +#include #include namespace activemq @@ -31,9 +32,9 @@ namespace util /** * Class controls the conversion of data contained in a PrimitiveValueNode - * from one type to another. If the conversion is supported then calling - * the convert method will throw an UnsupportedOperationException to - * indicate that its not possible to perform the conversion. + * from one type to another. If the conversion is not supported then + * calling the convert method will throw std::logic_error to indicate that + * its not possible to perform the conversion. * * This class is used to implement the rules of conversion on CMS Message * properties, the following conversion table must be implemented. A value @@ -67,7 +68,7 @@ namespace util template TO convert(const PrimitiveValueNode& value DECAF_UNUSED) const { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Invalid Conversion"); diff --git a/activemq-cpp/src/main/activemq/util/PrimitiveValueNode.cpp b/activemq-cpp/src/main/activemq/util/PrimitiveValueNode.cpp index 71a892177..d32dd1729 100644 --- a/activemq-cpp/src/main/activemq/util/PrimitiveValueNode.cpp +++ b/activemq-cpp/src/main/activemq/util/PrimitiveValueNode.cpp @@ -19,16 +19,18 @@ #include #include -#include #include #include #include +#include +#include #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include +#include #endif using namespace std; @@ -330,7 +332,7 @@ bool PrimitiveValueNode::getBool() const { if (valueType != BOOLEAN_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not BOOLEAN_TYPE"); @@ -352,7 +354,7 @@ unsigned char PrimitiveValueNode::getByte() const { if (valueType != BYTE_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not BYTE_TYPE"); @@ -374,7 +376,7 @@ char PrimitiveValueNode::getChar() const { if (valueType != CHAR_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not CHAR_TYPE"); @@ -396,7 +398,7 @@ short PrimitiveValueNode::getShort() const { if (valueType != SHORT_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not SHORT_TYPE"); @@ -418,7 +420,7 @@ int PrimitiveValueNode::getInt() const { if (valueType != INTEGER_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not INTEGER_TYPE"); @@ -440,7 +442,7 @@ long long PrimitiveValueNode::getLong() const { if (valueType != LONG_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not LONG_TYPE"); @@ -462,7 +464,7 @@ double PrimitiveValueNode::getDouble() const { if (valueType != DOUBLE_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not DOUBLE_TYPE"); @@ -484,7 +486,7 @@ float PrimitiveValueNode::getFloat() const { if (valueType != FLOAT_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not FLOAT_TYPE"); @@ -506,7 +508,7 @@ std::string PrimitiveValueNode::getString() const { if (valueType != STRING_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not STRING_TYPE"); @@ -533,7 +535,7 @@ std::vector PrimitiveValueNode::getByteArray() const { if (valueType != BYTE_ARRAY_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not BYTE_ARRAY_TYPE"); @@ -562,7 +564,7 @@ const decaf::util::List& PrimitiveValueNode::getList() const { if (valueType != LIST_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not LIST_TYPE"); @@ -570,7 +572,7 @@ const decaf::util::List& PrimitiveValueNode::getList() const if (value.listValue == NULL) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not set but an element was placed in the Map"); @@ -595,7 +597,7 @@ PrimitiveValueNode::getMap() const { if (valueType != MAP_TYPE) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "PrimitiveValue is not MAP_TYPE"); @@ -603,7 +605,7 @@ PrimitiveValueNode::getMap() const if (value.mapValue == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "PrimitiveValue is not set but an element was placed in the Map"); diff --git a/activemq-cpp/src/main/activemq/util/PrimitiveValueNode.h b/activemq-cpp/src/main/activemq/util/PrimitiveValueNode.h index 6c14ba41a..b16959def 100644 --- a/activemq-cpp/src/main/activemq/util/PrimitiveValueNode.h +++ b/activemq-cpp/src/main/activemq/util/PrimitiveValueNode.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include namespace activemq { @@ -241,7 +241,7 @@ namespace util /** * Gets the Boolean value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ bool getBool() const; @@ -257,7 +257,7 @@ namespace util /** * Gets the Byte value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ unsigned char getByte() const; @@ -273,7 +273,7 @@ namespace util /** * Gets the Character value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ char getChar() const; @@ -289,7 +289,7 @@ namespace util /** * Gets the Short value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ short getShort() const; @@ -305,7 +305,7 @@ namespace util /** * Gets the Integer value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ int getInt() const; @@ -321,7 +321,7 @@ namespace util /** * Gets the Long value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ long long getLong() const; @@ -337,7 +337,7 @@ namespace util /** * Gets the Float value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ float getFloat() const; @@ -353,7 +353,7 @@ namespace util /** * Gets the Double value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ double getDouble() const; @@ -369,7 +369,7 @@ namespace util /** * Gets the String value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ std::string getString() const; @@ -385,7 +385,7 @@ namespace util /** * Gets the Byte Array value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ std::vector getByteArray() const; @@ -401,7 +401,7 @@ namespace util /** * Gets the Primitive List value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ const decaf::util::List& getList() const; @@ -418,7 +418,7 @@ namespace util /** * Gets the Primitive Map value of this Node. * @return value contained at the given index - * @throw NoSuchElementException this node cannot be returned as the + * @throw std::runtime_error this node cannot be returned as the * requested type. */ const decaf::util::Map& getMap() const; diff --git a/activemq-cpp/src/main/activemq/util/ServiceStopper.cpp b/activemq-cpp/src/main/activemq/util/ServiceStopper.cpp index 460e63a5e..e909413c5 100644 --- a/activemq-cpp/src/main/activemq/util/ServiceStopper.cpp +++ b/activemq-cpp/src/main/activemq/util/ServiceStopper.cpp @@ -20,6 +20,8 @@ #include #include +#include + using namespace activemq; using namespace activemq::util; using namespace activemq::exceptions; @@ -50,14 +52,19 @@ void ServiceStopper::stop(Service* service) { service->stop(); } - catch (Exception& ex) - { - this->onException(service, ex); - } - catch (std::exception& stdex) + catch (const std::exception& stdex) { - ActiveMQException wrapper(__FILE__, __LINE__, stdex.what()); - this->onException(service, wrapper); + const Exception* dex = dynamic_cast(&stdex); + if (dex != nullptr) + { + Exception copy(*dex); + this->onException(service, copy); + } + else + { + ActiveMQException wrapper(__FILE__, __LINE__, stdex.what()); + this->onException(service, wrapper); + } } catch (...) { diff --git a/activemq-cpp/src/main/activemq/util/URISupport.cpp b/activemq-cpp/src/main/activemq/util/URISupport.cpp index 5d9ca9de1..25ce9bae5 100644 --- a/activemq-cpp/src/main/activemq/util/URISupport.cpp +++ b/activemq-cpp/src/main/activemq/util/URISupport.cpp @@ -19,12 +19,16 @@ #include +#include +#include #include -#include #include #include #include +#include #include +#include +#include using namespace std; using namespace activemq; @@ -32,7 +36,6 @@ using namespace activemq::util; using namespace decaf::util; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// bool URISupport::isCompositeURI(const URI& uri) @@ -60,13 +63,11 @@ void URISupport::parseURL(const std::string& URI, // transport, url, port. if (tokenizer.countTokens() < 3) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - (string("URISupport::parseURL - " - "Marlformed URI: ") + - URI) - .c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + string("URISupport::parseURL - " + "Marlformed URI: ") + + URI); } // First element should be the Transport Type, following that is the @@ -88,13 +89,12 @@ void URISupport::parseURL(const std::string& URI, if (tokenizer.countTokens() != 2) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - (string("URISupport::parseURL - " - "Marlformed Parameter = ") + - tokens[i]) - .c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + + string("URISupport::parseURL - " + "Marlformed Parameter = ") + + tokens[i]); } // Get them in order, passing both as nextToken calls in the @@ -106,9 +106,28 @@ void URISupport::parseURL(const std::string& URI, properties.setProperty(key, value); } } - AMQ_CATCH_RETHROW(IllegalArgumentException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IllegalArgumentException) - AMQ_CATCHALL_THROW(IllegalArgumentException) + catch (std::invalid_argument&) + { + throw; + } + catch (const std::exception& ex) + { + const decaf::lang::Exception* dex = + dynamic_cast(&ex); + if (dex != nullptr) + { + throw activemq::exceptions::InvalidArgumentException( + dex->getMessage()); + } + throw activemq::exceptions::InvalidArgumentException( + std::string(ex.what())); + } + catch (...) + { + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -120,9 +139,28 @@ Properties URISupport::parseQuery(std::string query) URISupport::parseQuery(query, &options); return options; } - AMQ_CATCH_RETHROW(IllegalArgumentException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IllegalArgumentException) - AMQ_CATCHALL_THROW(IllegalArgumentException) + catch (std::invalid_argument&) + { + throw; + } + catch (const std::exception& ex) + { + const decaf::lang::Exception* dex = + dynamic_cast(&ex); + if (dex != nullptr) + { + throw activemq::exceptions::InvalidArgumentException( + dex->getMessage()); + } + throw activemq::exceptions::InvalidArgumentException( + std::string(ex.what())); + } + catch (...) + { + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -132,10 +170,10 @@ void URISupport::parseQuery(std::string query, Properties* properties) { if (properties == NULL) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "URISupport::parseQuery - Can't " - "pass in a null properties object"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "URISupport::parseQuery - Can't " + "pass in a null properties object"); } // strip the initial "?" @@ -161,10 +199,9 @@ void URISupport::parseQuery(std::string query, Properties* properties) if (tokenizer.countTokens() != 2) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "URISupport::parseQuery - Invalid URI Option."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "URISupport::parseQuery - Invalid URI Option."); } // Get the Key @@ -183,9 +220,28 @@ void URISupport::parseQuery(std::string query, Properties* properties) properties->setProperty(key, value); } } - AMQ_CATCH_RETHROW(IllegalArgumentException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IllegalArgumentException) - AMQ_CATCHALL_THROW(IllegalArgumentException) + catch (std::invalid_argument&) + { + throw; + } + catch (const std::exception& ex) + { + const decaf::lang::Exception* dex = + dynamic_cast(&ex); + if (dex != nullptr) + { + throw activemq::exceptions::InvalidArgumentException( + dex->getMessage()); + } + throw activemq::exceptions::InvalidArgumentException( + std::string(ex.what())); + } + catch (...) + { + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -201,11 +257,11 @@ std::string URISupport::replaceEnvValues(const std::string& value) if (value.size() > 3 && value.at(1) != '{' && value.at(value.size() - 1) != '}') { - throw new decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "URISupport::replaceEnvValues - Invalid Env Var Syntax: %s", - value.c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + + "URISupport::replaceEnvValues - Invalid Env Var Syntax: " + + value); } string var = value.substr(2, value.size() - 3); @@ -213,11 +269,10 @@ std::string URISupport::replaceEnvValues(const std::string& value) if (var == "") { - throw new decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "URISupport::replaceEnvValues - Env Var not set: %s", - value.c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + + "URISupport::replaceEnvValues - Env Var not set: " + value); } return var; @@ -225,9 +280,28 @@ std::string URISupport::replaceEnvValues(const std::string& value) return value; } - AMQ_CATCH_RETHROW(IllegalArgumentException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IllegalArgumentException) - AMQ_CATCHALL_THROW(IllegalArgumentException) + catch (std::invalid_argument&) + { + throw; + } + catch (const std::exception& ex) + { + const decaf::lang::Exception* dex = + dynamic_cast(&ex); + if (dex != nullptr) + { + throw activemq::exceptions::InvalidArgumentException( + dex->getMessage()); + } + throw activemq::exceptions::InvalidArgumentException( + std::string(ex.what())); + } + catch (...) + { + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/util/URISupport.h b/activemq-cpp/src/main/activemq/util/URISupport.h index f88aaa658..5447e078f 100644 --- a/activemq-cpp/src/main/activemq/util/URISupport.h +++ b/activemq-cpp/src/main/activemq/util/URISupport.h @@ -20,9 +20,9 @@ #include #include -#include #include #include +#include namespace activemq { @@ -47,7 +47,7 @@ namespace util * them in the passed Properties Object. * @param URI a Broker URI to parse * @param properties a Properties object to set the parsed values in - * @throws IllegalArgumentException if the passed URI is invalid + * @throws std::invalid_argument if the passed URI is invalid */ static void parseURL(const std::string& URI, decaf::util::Properties& properties); @@ -74,7 +74,7 @@ namespace util * * @return Properties object with the parsed output. * - * @throw IllegalArgumentException if the Query string is not well + * @throws std::invalid_argument if the Query string is not well * formed. */ static decaf::util::Properties parseQuery(std::string query); @@ -86,7 +86,7 @@ namespace util * @param query - the query string to parse. * @param properties - object pointer to get the parsed output. * - * @throw IllegalArgumentException if the Query string is not well + * @throws std::invalid_argument if the Query string is not well * formed. */ static void parseQuery(std::string query, @@ -256,11 +256,10 @@ namespace util * Accepts a string value and checks to see if that value is of the * form ${XXX} which is our accepted form for environment variables. * If so the we attempt to replace the value with what is stored in that - * env var, if the var is not set then we throw an - * IllegalArgumentException. + * env var, if the var is not set then we throw std::invalid_argument. * @param value - the value to check for env * @return the env var if value points to an env var else returns value - * @throws IllegalArgumentException if the var is not set or has bad + * @throws std::invalid_argument if the var is not set or has bad * syntax */ static std::string replaceEnvValues(const std::string& value); diff --git a/activemq-cpp/src/main/activemq/wireformat/MarshalAware.h b/activemq-cpp/src/main/activemq/wireformat/MarshalAware.h index 808a3b9d0..e920a229e 100644 --- a/activemq-cpp/src/main/activemq/wireformat/MarshalAware.h +++ b/activemq-cpp/src/main/activemq/wireformat/MarshalAware.h @@ -18,8 +18,8 @@ #ifndef _ACTIVEMQ_WIREFORMAT_MARSHALAWARE_H_ #define _ACTIVEMQ_WIREFORMAT_MARSHALAWARE_H_ +#include #include -#include #include namespace activemq diff --git a/activemq-cpp/src/main/activemq/wireformat/WireFormat.h b/activemq-cpp/src/main/activemq/wireformat/WireFormat.h index 7358585a7..5b10b0f0e 100644 --- a/activemq-cpp/src/main/activemq/wireformat/WireFormat.h +++ b/activemq-cpp/src/main/activemq/wireformat/WireFormat.h @@ -20,16 +20,16 @@ #include +#include #include #include -#include #include #include #include -#include #include +#include namespace activemq { @@ -124,7 +124,7 @@ namespace wireformat * @return new instance of a WireFormatNegotiator as a * Pointer. * - * @throws UnsupportedOperationException if the WireFormat doesn't have + * @throws std::logic_error if the WireFormat doesn't have * a Negotiator. */ virtual std::shared_ptr createNegotiator( diff --git a/activemq-cpp/src/main/activemq/wireformat/WireFormatFactory.h b/activemq-cpp/src/main/activemq/wireformat/WireFormatFactory.h index dd3fc80dd..ec2406c35 100644 --- a/activemq-cpp/src/main/activemq/wireformat/WireFormatFactory.h +++ b/activemq-cpp/src/main/activemq/wireformat/WireFormatFactory.h @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -49,7 +48,7 @@ namespace wireformat * * @return Pointer to a new instance of a WireFormat object. * - * @throws IllegalStateException if the factory has not been + * @throws std::logic_error if the factory has not been * initialized. */ virtual std::shared_ptr createWireFormat( diff --git a/activemq-cpp/src/main/activemq/wireformat/WireFormatRegistry.cpp b/activemq-cpp/src/main/activemq/wireformat/WireFormatRegistry.cpp index d8f392e36..01b01ad65 100644 --- a/activemq-cpp/src/main/activemq/wireformat/WireFormatRegistry.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/WireFormatRegistry.cpp @@ -17,15 +17,15 @@ #include "WireFormatRegistry.h" +#include #include +#include using namespace std; using namespace activemq; using namespace activemq::wireformat; using namespace decaf; using namespace decaf::util; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace @@ -56,11 +56,11 @@ WireFormatFactory* WireFormatRegistry::findFactory(const std::string& name) cons { if (!this->registry.containsKey(name)) { - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, - "No Matching Factory Registered for format := %s", - name.c_str()); + std::string("No Matching Factory Registered for format := ") + + name); } return this->registry.get(name); @@ -72,17 +72,13 @@ void WireFormatRegistry::registerFactory(const std::string& name, { if (name == "") { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::IllegalArgumentException( "WireFormatFactory name cannot be the empty string"); } if (factory == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Supplied WireFormatFactory pointer was NULL"); } diff --git a/activemq-cpp/src/main/activemq/wireformat/WireFormatRegistry.h b/activemq-cpp/src/main/activemq/wireformat/WireFormatRegistry.h index 1cf4ecc2f..199eb1d2a 100644 --- a/activemq-cpp/src/main/activemq/wireformat/WireFormatRegistry.h +++ b/activemq-cpp/src/main/activemq/wireformat/WireFormatRegistry.h @@ -24,10 +24,8 @@ #include #include -#include -#include -#include #include +#include namespace activemq { @@ -74,7 +72,7 @@ namespace wireformat * * @return the Factory registered under the given name. * - * @throws NoSuchElementException if no factory is registered with that + * @throws std::runtime_error if no factory is registered with that * name. */ WireFormatFactory* findFactory(const std::string& name) const; @@ -91,8 +89,8 @@ namespace wireformat * @param factory * The new Factory to add to the Registry. * - * @throws IllegalArgumentException is name is the empty string. - * @throws NullPointerException if the Factory is Null. + * @throws std::invalid_argument is name is the empty string. + * @throws std::invalid_argument if the Factory is Null. */ void registerFactory(const std::string& name, WireFormatFactory* factory); diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp index 16643f711..01fd04a62 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp @@ -21,6 +21,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -29,9 +32,14 @@ #include #include #include +#include +#include #include #include #include +#include +#include +#include using namespace std; using namespace activemq; @@ -43,11 +51,13 @@ using namespace activemq::wireformat; using namespace activemq::wireformat::openwire; using namespace activemq::wireformat::openwire::marshal; using namespace activemq::wireformat::openwire::utils; -using namespace decaf::io; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang:: - exceptions; //////////////////////////////////////////////////////////////////////////////// + +using decaf::io::ByteArrayOutputStream; +using decaf::io::DataInputStream; +using decaf::io::DataOutputStream; + const unsigned char OpenWireFormat::NULL_TYPE = 0; const int OpenWireFormat::DEFAULT_VERSION = 1; const int OpenWireFormat::MAX_SUPPORTED_VERSION = 11; @@ -98,8 +108,13 @@ std::shared_ptr OpenWireFormat::createNegotiator( return std::shared_ptr( new OpenWireFormatNegotiator(this, transport)); } - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCHALL_THROW(UnsupportedOperationException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + catch (...) + { + throw activemq::exceptions::TypeMismatchException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -129,19 +144,25 @@ void OpenWireFormat::setVersion(int version) if (version > MAX_SUPPORTED_VERSION) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "OpenWireFormat::setVersion - " - "Given Version: %d , is not yet supported", - version); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "OpenWireFormat::setVersion - Given Version: " + + std::to_string(version) + " , is not yet supported"); } // Clear old marshalers in preparation for the new set. this->version = version; } - AMQ_CATCH_RETHROW(IllegalArgumentException) - AMQ_CATCHALL_THROW(IllegalArgumentException) + catch (std::invalid_argument&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -165,16 +186,17 @@ void OpenWireFormat::marshal(const std::shared_ptr command, { if (transport == NULL) { - throw decaf::io::IOException(__FILE__, - __LINE__, - "Transport passed is NULL"); + throw activemq::exceptions::IOException(__FILE__, + __LINE__, + "Transport passed is NULL"); } if (dataOut == NULL) { - throw decaf::io::IOException(__FILE__, - __LINE__, - "DataOutputStream passed is NULL"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "DataOutputStream passed is NULL"); } try @@ -192,7 +214,7 @@ void OpenWireFormat::marshal(const std::shared_ptr command, if (dsm == NULL) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, (string("OpenWireFormat::marshal - Unknown data type: ") + @@ -244,7 +266,7 @@ void OpenWireFormat::marshal(const std::shared_ptr command, { dataOut->write(array.first, array.second); } - catch (Exception& ex) + catch (const std::exception&) { delete[] array.first; throw; @@ -261,10 +283,10 @@ void OpenWireFormat::marshal(const std::shared_ptr command, dataOut->writeByte(NULL_TYPE); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -276,9 +298,10 @@ std::shared_ptr OpenWireFormat::unmarshal( { if (dis == NULL) { - throw decaf::io::IOException(__FILE__, - __LINE__, - "DataInputStream passed is NULL"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "DataInputStream passed is NULL"); } if (!sizePrefixDisabled) @@ -291,24 +314,25 @@ std::shared_ptr OpenWireFormat::unmarshal( if (!data) { - throw IOException(__FILE__, - __LINE__, - "OpenWireFormat::doUnmarshal - " - "Failed to unmarshal an Object"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "OpenWireFormat::doUnmarshal - " + "Failed to unmarshal an Object"); } // Now all unmarshals from this level should result in an object - // that is a commands::Command type, if its not then the cast will - // throw an ClassCastException. + // that is a commands::Command type; otherwise dynamic_pointer_cast + // yields null. std::shared_ptr command = std::dynamic_pointer_cast(data); return command; } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -365,7 +389,7 @@ commands::DataStructure* OpenWireFormat::doUnmarshal( if (dsm == NULL) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, (string("OpenWireFormat::marshal - Unknown data type: ") + @@ -393,10 +417,10 @@ commands::DataStructure* OpenWireFormat::doUnmarshal( return NULL; } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -425,7 +449,7 @@ int OpenWireFormat::tightMarshalNestedObject1(commands::DataStructure* object, unsigned char type = object->getDataStructureType(); if (type == 0) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "No valid data structure type for object of this type"); @@ -435,7 +459,7 @@ int OpenWireFormat::tightMarshalNestedObject1(commands::DataStructure* object, if (dsm == NULL) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, (string("OpenWireFormat::marshal - Unknown data type: ") + @@ -445,10 +469,10 @@ int OpenWireFormat::tightMarshalNestedObject1(commands::DataStructure* object, return 1 + dsm->tightMarshal1(this, object, bs); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -479,7 +503,7 @@ void OpenWireFormat::tightMarshalNestedObject2(DataStructure* o, if (dsm == NULL) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, (string("OpenWireFormat::marshal - Unknown data type: ") + @@ -490,10 +514,10 @@ void OpenWireFormat::tightMarshalNestedObject2(DataStructure* o, dsm->tightMarshal2(this, o, ds, bs); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -510,7 +534,7 @@ DataStructure* OpenWireFormat::tightUnmarshalNestedObject(DataInputStream* dis, if (dsm == NULL) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, (string("OpenWireFormat::marshal - Unknown data type: ") + @@ -542,10 +566,10 @@ DataStructure* OpenWireFormat::tightUnmarshalNestedObject(DataInputStream* dis, return NULL; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -562,7 +586,7 @@ DataStructure* OpenWireFormat::looseUnmarshalNestedObject( if (dsm == NULL) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, (string("OpenWireFormat::marshal - Unknown data type: ") + @@ -579,10 +603,10 @@ DataStructure* OpenWireFormat::looseUnmarshalNestedObject( return NULL; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -603,7 +627,7 @@ void OpenWireFormat::looseMarshalNestedObject( if (dsm == NULL) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, (string("OpenWireFormat::marshal - Unknown data type: ") + @@ -614,10 +638,10 @@ void OpenWireFormat::looseMarshalNestedObject( dsm->looseMarshal(this, o, dataOut); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -625,10 +649,10 @@ void OpenWireFormat::renegotiateWireFormat(const WireFormatInfo& info) { if (!preferedWireFormatInfo) { - throw IllegalStateException(__FILE__, - __LINE__, - "OpenWireFormat::renegotiateWireFormat - " - "Wireformat cannot not be renegotiated."); + throw activemq::exceptions::TypeMismatchException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "OpenWireFormat::renegotiateWireFormat - " + "Wireformat cannot not be renegotiated."); } this->setVersion( diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.h b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.h index 9fce1c91b..27f10cb78 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.h @@ -23,11 +23,10 @@ #include #include #include -#include -#include #include #include #include +#include namespace activemq { @@ -197,7 +196,7 @@ namespace wireformat * @param info * The new Wireformat Info settings. * - * @throws IllegalStateException is wire format can't be negotiated. + * @throws std::logic_error is wire format can't be negotiated. */ void renegotiateWireFormat(const commands::WireFormatInfo& info); @@ -207,7 +206,7 @@ namespace wireformat * @param info * A WireFormatInfo object, takes ownership. * - * @throws IllegalStateException if the WireFormat object has not + * @throws std::logic_error if the WireFormat object has not * been initialized. */ void setPreferedWireFormatInfo( @@ -274,7 +273,7 @@ namespace wireformat * @param version * An int that identifies the version * - * @throws IllegalArgumentException if the version given is not + * @throws std::invalid_argument if the version given is not * supported. */ void setVersion(int version); diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.cpp index 2aed408a7..7faa395c7 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.cpp @@ -20,8 +20,12 @@ #include +#include +#include #include #include +#include +#include using namespace std; using namespace activemq; @@ -33,7 +37,6 @@ using namespace activemq::exceptions; using namespace activemq::wireformat; using namespace activemq::wireformat::openwire; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// std::shared_ptr OpenWireFormatFactory::createWireFormat( @@ -85,6 +88,11 @@ std::shared_ptr OpenWireFormatFactory::createWireFormat( return wireFormat; } - AMQ_CATCH_RETHROW(IllegalStateException) - AMQ_CATCHALL_THROW(IllegalStateException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + catch (...) + { + throw activemq::exceptions::TypeMismatchException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.h b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.h index acc5a2393..e0f9b3d49 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatNegotiator.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatNegotiator.cpp index 5092d3246..1d27fef9c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatNegotiator.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatNegotiator.cpp @@ -19,8 +19,11 @@ #include #include +#include +#include #include #include +#include using namespace std; using namespace activemq; @@ -34,7 +37,6 @@ using activemq::util::AMQLogger; using namespace decaf::util::concurrent; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// const int OpenWireFormatNegotiator::negotiationTimeout = 15000; @@ -76,11 +78,12 @@ void OpenWireFormatNegotiator::oneway(const std::shared_ptr command) if (!readyCountDownLatch.await(negotiationTimeout)) { - throw IOException(__FILE__, - __LINE__, - "OpenWireFormatNegotiator::oneway" - "Wire format negotiation timeout: peer did not " - "send his wire format."); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "OpenWireFormatNegotiator::oneway" + "Wire format negotiation timeout: peer did not " + "send his wire format."); } AMQ_LOG_DEBUG( @@ -91,10 +94,11 @@ void OpenWireFormatNegotiator::oneway(const std::shared_ptr command) next->oneway(command); } - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -107,19 +111,21 @@ std::shared_ptr OpenWireFormatNegotiator::request( if (!readyCountDownLatch.await(negotiationTimeout)) { - throw IOException(__FILE__, - __LINE__, - "OpenWireFormatNegotiator::request" - "Wire format negotiation timeout: peer did not " - "send his wire format."); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "OpenWireFormatNegotiator::request" + "Wire format negotiation timeout: peer did not " + "send his wire format."); } return next->request(command); } - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -133,19 +139,21 @@ std::shared_ptr OpenWireFormatNegotiator::request( if (!readyCountDownLatch.await(negotiationTimeout)) { - throw IOException(__FILE__, - __LINE__, - "OpenWireFormatNegotiator::request" - "Wire format negotiation timeout: peer did not " - "send his wire format."); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "OpenWireFormatNegotiator::request" + "Wire format negotiation timeout: peer did not " + "send his wire format."); } return next->request(command, timeout); } - AMQ_CATCH_RETHROW(UnsupportedOperationException) - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -159,10 +167,11 @@ void OpenWireFormatNegotiator::onCommand(const std::shared_ptr command) { if (!info->isValid()) { - throw IOException(__FILE__, - __LINE__, - "OpenWireFormatNegotiator::onCommand" - "Remote wire format magic is invalid"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "OpenWireFormatNegotiator::onCommand" + "Remote wire format magic is invalid"); } AMQ_LOG_DEBUG("OpenWireFormatNegotiator", @@ -220,12 +229,17 @@ void OpenWireFormatNegotiator::afterNextIsStarted() // Mark the latch wireInfoSentDownLatch.countDown(); } - catch (decaf::lang::Exception& ex) + catch (activemq::exceptions::ActiveMQException& ex) { // Mark the latch wireInfoSentDownLatch.countDown(); ex.setMark(__FILE__, __LINE__); throw; } + catch (std::exception&) + { + wireInfoSentDownLatch.countDown(); + throw; + } } } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.cpp index ecb85f49b..7d62cb15f 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.cpp @@ -54,9 +54,9 @@ commands::DataStructure* BaseDataStreamMarshaller::tightUnmarshalCachedObject( { return wireFormat->tightUnmarshalNestedObject(dataIn, bs); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -69,9 +69,9 @@ int BaseDataStreamMarshaller::tightMarshalCachedObject1( { return wireFormat->tightMarshalNestedObject1(data, bs); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -85,9 +85,9 @@ void BaseDataStreamMarshaller::tightMarshalCachedObject2( { wireFormat->tightMarshalNestedObject2(data, dataOut, bs); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -100,9 +100,9 @@ void BaseDataStreamMarshaller::looseMarshalCachedObject( { wireFormat->looseMarshalNestedObject(data, dataOut); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -114,9 +114,9 @@ commands::DataStructure* BaseDataStreamMarshaller::looseUnmarshalCachedObject( { return wireFormat->looseUnmarshalNestedObject(dataIn); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -129,9 +129,9 @@ int BaseDataStreamMarshaller::tightMarshalNestedObject1( { return wireFormat->tightMarshalNestedObject1(object, bs); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -145,9 +145,9 @@ void BaseDataStreamMarshaller::tightMarshalNestedObject2( { wireFormat->tightMarshalNestedObject2(object, dataOut, bs); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -160,9 +160,9 @@ commands::DataStructure* BaseDataStreamMarshaller::tightUnmarshalNestedObject( { return wireFormat->tightUnmarshalNestedObject(dataIn, bs); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -174,9 +174,9 @@ commands::DataStructure* BaseDataStreamMarshaller::looseUnmarshalNestedObject( { return wireFormat->looseUnmarshalNestedObject(dataIn); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -189,9 +189,9 @@ void BaseDataStreamMarshaller::looseMarshalNestedObject( { wireFormat->looseMarshalNestedObject(object, dataOut); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -217,9 +217,9 @@ std::string BaseDataStreamMarshaller::tightUnmarshalString( return ""; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -258,7 +258,7 @@ int BaseDataStreamMarshaller::tightMarshalString1(const std::string& value, if (utflen >= 0x10000) { - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "BaseDataStreamMarshaller::tightMarshalString1 - " @@ -274,9 +274,10 @@ int BaseDataStreamMarshaller::tightMarshalString1(const std::string& value, return 0; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -301,9 +302,9 @@ void BaseDataStreamMarshaller::tightMarshalString2( } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -319,9 +320,9 @@ void BaseDataStreamMarshaller::looseMarshalString( dataOut->writeUTF(value); } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -339,9 +340,9 @@ std::string BaseDataStreamMarshaller::looseUnmarshalString( return ""; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -381,9 +382,9 @@ int BaseDataStreamMarshaller::tightMarshalLong1(OpenWireFormat* wireFormat } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -414,9 +415,9 @@ void BaseDataStreamMarshaller::tightMarshalLong2( } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -450,9 +451,9 @@ long long BaseDataStreamMarshaller::tightUnmarshalLong( } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -465,9 +466,9 @@ void BaseDataStreamMarshaller::looseMarshalLong( { dataOut->writeLong(value); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -479,9 +480,9 @@ long long BaseDataStreamMarshaller::looseUnmarshalLong( { return dataIn->readLong(); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -530,9 +531,9 @@ commands::DataStructure* BaseDataStreamMarshaller::tightUnmarshalBrokerError( return NULL; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -580,9 +581,9 @@ int BaseDataStreamMarshaller::tightMarshalBrokerError1( return rc; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -624,9 +625,9 @@ void BaseDataStreamMarshaller::tightMarshalBrokerError2( } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -674,9 +675,9 @@ commands::DataStructure* BaseDataStreamMarshaller::looseUnmarshalBrokerError( return NULL; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -720,9 +721,9 @@ void BaseDataStreamMarshaller::looseMarshalBrokerError( } } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -745,9 +746,9 @@ std::vector BaseDataStreamMarshaller::tightUnmarshalByteArray( return data; } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -770,9 +771,9 @@ std::vector BaseDataStreamMarshaller::looseUnmarshalByteArray( return std::vector(); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -792,9 +793,9 @@ BaseDataStreamMarshaller::tightUnmarshalConstByteArray( } return data; } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -813,9 +814,9 @@ BaseDataStreamMarshaller::looseUnmarshalConstByteArray( } return data; } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -894,7 +895,7 @@ std::string BaseDataStreamMarshaller::readAsciiString( return text; } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.h index 3a1137bb8..28002773c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -554,10 +555,9 @@ namespace wireformat return 0; } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /** @@ -591,10 +591,9 @@ namespace wireformat } } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /** @@ -626,10 +625,9 @@ namespace wireformat } } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } protected: diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/DataStreamMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/DataStreamMarshaller.h index 6718dea4a..5f2180a89 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/DataStreamMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/DataStreamMarshaller.h @@ -19,12 +19,12 @@ #define _ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSHAL_DATASTREAMMARSHALLER_H_ #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshaller.cpp index cafb2596d..a4139e424 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshaller.cpp @@ -18,6 +18,7 @@ #include "PrimitiveTypesMarshaller.h" #include +#include #include #include #include @@ -228,9 +229,9 @@ void PrimitiveTypesMarshaller::marshalPrimitiveMap( marshalPrimitive(dataOut, value); } } - AMQ_CATCH_RETHROW(io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, io::IOException) - AMQ_CATCHALL_THROW(io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -247,9 +248,9 @@ void PrimitiveTypesMarshaller::marshalPrimitiveList( marshalPrimitive(dataOut, list.get(ix)); } } - AMQ_CATCH_RETHROW(io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, io::IOException) - AMQ_CATCHALL_THROW(io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -349,14 +350,15 @@ void PrimitiveTypesMarshaller::marshalPrimitive( } else { - throw IOException(__FILE__, - __LINE__, - "Object is not a primitive: "); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "Object is not a primitive: "); } } - AMQ_CATCH_RETHROW(io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, io::IOException) - AMQ_CATCHALL_THROW(io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -377,9 +379,9 @@ void PrimitiveTypesMarshaller::unmarshalPrimitiveMap( } } } - AMQ_CATCH_RETHROW(io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, io::IOException) - AMQ_CATCHALL_THROW(io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -395,9 +397,9 @@ void PrimitiveTypesMarshaller::unmarshalPrimitiveList( list.add(unmarshalPrimitive(dataIn)); } } - AMQ_CATCH_RETHROW(io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, io::IOException) - AMQ_CATCHALL_THROW(io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -492,7 +494,7 @@ PrimitiveValueNode PrimitiveTypesMarshaller::unmarshalPrimitive( break; } default: - throw IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "PrimitiveTypesMarshaller::unmarshalPrimitive - " @@ -501,7 +503,7 @@ PrimitiveValueNode PrimitiveTypesMarshaller::unmarshalPrimitive( return value; } - AMQ_CATCH_RETHROW(io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, io::IOException) - AMQ_CATCHALL_THROW(io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshaller.h index 6379bcd29..4dd19d3ce 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshaller.h @@ -18,6 +18,7 @@ #ifndef _ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSHAL_PRIMITIVETYPESMARSHALLER_H_ #define _ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSHAL_PRIMITIVETYPESMARSHALLER_H_ +#include #include #include #include @@ -25,7 +26,6 @@ #include #include #include -#include #include namespace activemq diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.cpp index 02b04a90f..b787226cf 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.cpp @@ -80,10 +80,9 @@ void ActiveMQBlobMessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setDeletedByBroker(bs->readBoolean()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -116,10 +115,9 @@ int ActiveMQBlobMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -150,10 +148,9 @@ void ActiveMQBlobMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs->readBoolean(); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -182,10 +179,9 @@ void ActiveMQBlobMessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setDeletedByBroker(dataIn->readBoolean()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -214,8 +210,7 @@ void ActiveMQBlobMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeBoolean(info->isDeletedByBroker()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.h index 31856d43d..f13dfe3ec 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.cpp index d8015780f..e922e5996 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.cpp @@ -68,10 +68,9 @@ void ActiveMQBytesMessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -90,10 +89,9 @@ int ActiveMQBytesMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -110,10 +108,9 @@ void ActiveMQBytesMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -129,10 +126,9 @@ void ActiveMQBytesMessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -148,8 +144,7 @@ void ActiveMQBytesMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.h index c52508807..e74cca1a2 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.cpp index a355a68b0..440c00914 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.cpp @@ -57,10 +57,9 @@ void ActiveMQDestinationMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->setPhysicalName(tightUnmarshalString(dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -80,10 +79,9 @@ int ActiveMQDestinationMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -103,10 +101,9 @@ void ActiveMQDestinationMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); tightMarshalString2(info->getPhysicalName(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -123,10 +120,9 @@ void ActiveMQDestinationMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->setPhysicalName(looseUnmarshalString(dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -143,8 +139,7 @@ void ActiveMQDestinationMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); looseMarshalString(info->getPhysicalName(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.h index 337fa9fc2..efaa3f490 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.cpp index e44fa0d42..e0d5a9815 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.cpp @@ -68,10 +68,9 @@ void ActiveMQMapMessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -90,10 +89,9 @@ int ActiveMQMapMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -110,10 +108,9 @@ void ActiveMQMapMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -129,10 +126,9 @@ void ActiveMQMapMessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -148,8 +144,7 @@ void ActiveMQMapMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.h index 20957c4b0..cc790c876 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.cpp index 08a906eff..a097515bd 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.cpp @@ -67,10 +67,9 @@ void ActiveMQMessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -88,10 +87,9 @@ int ActiveMQMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -107,10 +105,9 @@ void ActiveMQMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, ActiveMQMessage* info = dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -125,10 +122,9 @@ void ActiveMQMessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -143,8 +139,7 @@ void ActiveMQMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.h index 489214462..8a40d13a3 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.cpp index d518f109c..4255cc5d5 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.cpp @@ -69,10 +69,9 @@ void ActiveMQObjectMessageMarshaller::tightUnmarshal( info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -91,10 +90,9 @@ int ActiveMQObjectMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -111,10 +109,9 @@ void ActiveMQObjectMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -131,10 +128,9 @@ void ActiveMQObjectMessageMarshaller::looseUnmarshal( info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -150,8 +146,7 @@ void ActiveMQObjectMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.h index 58f05aad8..8f7603bd9 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.cpp index fb3a94ec6..c6dcc0ca0 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.cpp @@ -65,10 +65,9 @@ void ActiveMQQueueMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -84,10 +83,9 @@ int ActiveMQQueueMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -103,10 +101,9 @@ void ActiveMQQueueMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -120,10 +117,9 @@ void ActiveMQQueueMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -137,8 +133,7 @@ void ActiveMQQueueMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.h index da3bd0782..d22b333a4 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.cpp index 553165345..92a031afb 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.cpp @@ -69,10 +69,9 @@ void ActiveMQStreamMessageMarshaller::tightUnmarshal( info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -91,10 +90,9 @@ int ActiveMQStreamMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -111,10 +109,9 @@ void ActiveMQStreamMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -131,10 +128,9 @@ void ActiveMQStreamMessageMarshaller::looseUnmarshal( info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -150,8 +146,7 @@ void ActiveMQStreamMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.h index 47a74a39f..38a059f19 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.cpp index b5de3beda..9bb4eeeae 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.cpp @@ -54,10 +54,9 @@ void ActiveMQTempDestinationMarshaller::tightUnmarshal( dataIn, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -74,10 +73,9 @@ int ActiveMQTempDestinationMarshaller::tightMarshal1( return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -94,10 +92,9 @@ void ActiveMQTempDestinationMarshaller::tightMarshal2( dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -112,10 +109,9 @@ void ActiveMQTempDestinationMarshaller::looseUnmarshal( dataStructure, dataIn); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -130,8 +126,7 @@ void ActiveMQTempDestinationMarshaller::looseMarshal( dataStructure, dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.h index 2fa6e30ed..ed2dd0786 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.cpp index fe4c7d48d..56b131b5b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.cpp @@ -65,10 +65,9 @@ void ActiveMQTempQueueMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -84,10 +83,9 @@ int ActiveMQTempQueueMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -103,10 +101,9 @@ void ActiveMQTempQueueMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -120,10 +117,9 @@ void ActiveMQTempQueueMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -137,8 +133,7 @@ void ActiveMQTempQueueMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.h index 16174e265..c764340a3 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.cpp index a5bd79eae..0015f428b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.cpp @@ -65,10 +65,9 @@ void ActiveMQTempTopicMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -84,10 +83,9 @@ int ActiveMQTempTopicMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -103,10 +101,9 @@ void ActiveMQTempTopicMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -120,10 +117,9 @@ void ActiveMQTempTopicMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -137,8 +133,7 @@ void ActiveMQTempTopicMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.h index 3d9ff6b8d..0976cf8b1 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.cpp index 9800c3120..db2d00ebe 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.cpp @@ -68,10 +68,9 @@ void ActiveMQTextMessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -90,10 +89,9 @@ int ActiveMQTextMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -110,10 +108,9 @@ void ActiveMQTextMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -129,10 +126,9 @@ void ActiveMQTextMessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -148,8 +144,7 @@ void ActiveMQTextMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.h index 89e7c7c6d..10d7f72aa 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.cpp index bc2fde701..29981fa0c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.cpp @@ -65,10 +65,9 @@ void ActiveMQTopicMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -84,10 +83,9 @@ int ActiveMQTopicMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -103,10 +101,9 @@ void ActiveMQTopicMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -120,10 +117,9 @@ void ActiveMQTopicMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -137,8 +133,7 @@ void ActiveMQTopicMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.h index 4d0b6ed1f..c6fe6a3e8 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.cpp index 7b8fe7a79..bd9a365aa 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.cpp @@ -57,10 +57,9 @@ void BaseCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setCommandId(dataIn->readInt()); info->setResponseRequired(bs->readBoolean()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -79,10 +78,9 @@ int BaseCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -102,10 +100,9 @@ void BaseCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->writeInt(info->getCommandId()); bs->readBoolean(); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -122,10 +119,9 @@ void BaseCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setCommandId(dataIn->readInt()); info->setResponseRequired(dataIn->readBoolean()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -142,8 +138,7 @@ void BaseCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeInt(info->getCommandId()); dataOut->writeBoolean(info->isResponseRequired()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.h index 3186d9306..114d01c30 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.cpp index be83274d0..c77b04512 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.cpp @@ -68,10 +68,9 @@ void BrokerIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, BrokerId* info = dynamic_cast(dataStructure); info->setValue(tightUnmarshalString(dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -90,10 +89,9 @@ int BrokerIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -112,10 +110,9 @@ void BrokerIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, BrokerId* info = dynamic_cast(dataStructure); tightMarshalString2(info->getValue(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -131,10 +128,9 @@ void BrokerIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, BrokerId* info = dynamic_cast(dataStructure); info->setValue(looseUnmarshalString(dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -150,8 +146,7 @@ void BrokerIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); looseMarshalString(info->getValue(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.h index 824b6404c..f83337ce8 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.cpp index 48b60209e..9c39d1d0a 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.cpp @@ -113,10 +113,9 @@ void BrokerInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setNetworkProperties(tightUnmarshalString(dataIn, bs)); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -167,10 +166,9 @@ int BrokerInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -224,10 +222,9 @@ void BrokerInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalString2(info->getNetworkProperties(), dataOut, bs); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -288,10 +285,9 @@ void BrokerInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setNetworkProperties(looseUnmarshalString(dataIn)); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -338,8 +334,7 @@ void BrokerInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalString(info->getNetworkProperties(), dataOut); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.h index 1be5bb67b..b71df1fe8 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.cpp index 24afb28e4..60fb6ade9 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.cpp @@ -92,10 +92,9 @@ void ConnectionControlMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setToken(tightUnmarshalByteArray(dataIn, bs)); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -140,10 +139,9 @@ int ConnectionControlMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -193,10 +191,9 @@ void ConnectionControlMarshaller::tightMarshal2(OpenWireFormat* wireFormat, } } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -236,10 +233,9 @@ void ConnectionControlMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setToken(looseUnmarshalByteArray(dataIn)); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -285,8 +281,7 @@ void ConnectionControlMarshaller::looseMarshal(OpenWireFormat* wireFormat, } } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.h index 0cb677141..a950946bf 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.cpp index 0da87e9d0..5a5b0b824 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.cpp @@ -73,10 +73,9 @@ void ConnectionErrorMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -99,10 +98,9 @@ int ConnectionErrorMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -128,10 +126,9 @@ void ConnectionErrorMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -152,10 +149,9 @@ void ConnectionErrorMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalNestedObject(wireFormat, dataIn)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -174,8 +170,7 @@ void ConnectionErrorMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getConnectionId().get(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.h index cd1d7d24d..54b2ad13c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.cpp index ae518eaef..389410369 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.cpp @@ -68,10 +68,9 @@ void ConnectionIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, ConnectionId* info = dynamic_cast(dataStructure); info->setValue(tightUnmarshalString(dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -90,10 +89,9 @@ int ConnectionIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -112,10 +110,9 @@ void ConnectionIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, ConnectionId* info = dynamic_cast(dataStructure); tightMarshalString2(info->getValue(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -131,10 +128,9 @@ void ConnectionIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, ConnectionId* info = dynamic_cast(dataStructure); info->setValue(looseUnmarshalString(dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -150,8 +146,7 @@ void ConnectionIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); looseMarshalString(info->getValue(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.h index 5570b38e1..d67ad4731 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.cpp index 92cbc128f..cd5820858 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.cpp @@ -110,10 +110,9 @@ void ConnectionInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setClientIp(tightUnmarshalString(dataIn, bs)); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -158,10 +157,9 @@ int ConnectionInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -208,10 +206,9 @@ void ConnectionInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalString2(info->getClientIp(), dataOut, bs); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -269,10 +266,9 @@ void ConnectionInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setClientIp(looseUnmarshalString(dataIn)); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -313,8 +309,7 @@ void ConnectionInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalString(info->getClientIp(), dataOut); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.h index 6f074f7b6..ff532f27a 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.cpp index a66caafda..08372483e 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.cpp @@ -93,10 +93,9 @@ void ConsumerControlMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setStop(bs->readBoolean()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -138,10 +137,9 @@ int ConsumerControlMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -187,10 +185,9 @@ void ConsumerControlMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs->readBoolean(); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -231,10 +228,9 @@ void ConsumerControlMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setStop(dataIn->readBoolean()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -273,8 +269,7 @@ void ConsumerControlMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeBoolean(info->isStop()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.h index 7a05ff6a5..adada5567 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.cpp index f46a444f6..945a3b354 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.cpp @@ -70,10 +70,9 @@ void ConsumerIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setSessionId(tightUnmarshalLong(wireFormat, dataIn, bs)); info->setValue(tightUnmarshalLong(wireFormat, dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -94,10 +93,9 @@ int ConsumerIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -118,10 +116,9 @@ void ConsumerIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalLong2(wireFormat, info->getSessionId(), dataOut, bs); tightMarshalLong2(wireFormat, info->getValue(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -139,10 +136,9 @@ void ConsumerIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setSessionId(looseUnmarshalLong(wireFormat, dataIn)); info->setValue(looseUnmarshalLong(wireFormat, dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -160,8 +156,7 @@ void ConsumerIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalLong(wireFormat, info->getSessionId(), dataOut); looseMarshalLong(wireFormat, info->getValue(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.h index 48846e9b5..a94173d9c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.cpp index 96d491341..4eb08cf98 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.cpp @@ -132,10 +132,9 @@ void ConsumerInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, } } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -185,10 +184,9 @@ int ConsumerInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 9; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -246,10 +244,9 @@ void ConsumerInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -327,10 +324,9 @@ void ConsumerInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, } } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -379,8 +375,7 @@ void ConsumerInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.h index adf69a1a1..b83c87af6 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.cpp index 590088578..d0743165b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.cpp @@ -68,10 +68,9 @@ void ControlCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, ControlCommand* info = dynamic_cast(dataStructure); info->setCommand(tightUnmarshalString(dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -89,10 +88,9 @@ int ControlCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -111,10 +109,9 @@ void ControlCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, ControlCommand* info = dynamic_cast(dataStructure); tightMarshalString2(info->getCommand(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -130,10 +127,9 @@ void ControlCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, ControlCommand* info = dynamic_cast(dataStructure); info->setCommand(looseUnmarshalString(dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -147,8 +143,7 @@ void ControlCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, BaseCommandMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); looseMarshalString(info->getCommand(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.h index 34313c8a0..4a3d87f45 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.cpp index 278db3003..2f14a5420 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.cpp @@ -84,10 +84,9 @@ void DataArrayResponseMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->getData().clear(); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -106,10 +105,9 @@ int DataArrayResponseMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -129,10 +127,9 @@ void DataArrayResponseMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); tightMarshalObjectArray2(wireFormat, info->getData(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -162,10 +159,9 @@ void DataArrayResponseMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->getData().clear(); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -180,8 +176,7 @@ void DataArrayResponseMarshaller::looseMarshal(OpenWireFormat* wireFormat, ResponseMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); looseMarshalObjectArray(wireFormat, info->getData(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.h index ef3c6d17d..2e9cfa9a4 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.cpp index e2ef71695..716fac82d 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.cpp @@ -70,10 +70,9 @@ void DataResponseMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -91,10 +90,9 @@ int DataResponseMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -116,10 +114,9 @@ void DataResponseMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -135,10 +132,9 @@ void DataResponseMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalNestedObject(wireFormat, dataIn)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -152,8 +148,7 @@ void DataResponseMarshaller::looseMarshal(OpenWireFormat* wireFormat, ResponseMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); looseMarshalNestedObject(wireFormat, info->getData().get(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.h index 15314c7d8..8e1cffd1a 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.cpp index f70f71b4f..5985b8f97 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.cpp @@ -91,10 +91,9 @@ void DestinationInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->getBrokerPath().clear(); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -119,10 +118,9 @@ int DestinationInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 1; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -151,10 +149,9 @@ void DestinationInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalLong2(wireFormat, info->getTimeout(), dataOut, bs); tightMarshalObjectArray2(wireFormat, info->getBrokerPath(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -193,10 +190,9 @@ void DestinationInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->getBrokerPath().clear(); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -218,8 +214,7 @@ void DestinationInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalLong(wireFormat, info->getTimeout(), dataOut); looseMarshalObjectArray(wireFormat, info->getBrokerPath(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.h index dab8ac144..89ad061f5 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.cpp index 895aaaf6d..05a5730f4 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.cpp @@ -69,10 +69,9 @@ void DiscoveryEventMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setServiceName(tightUnmarshalString(dataIn, bs)); info->setBrokerName(tightUnmarshalString(dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -92,10 +91,9 @@ int DiscoveryEventMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -115,10 +113,9 @@ void DiscoveryEventMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalString2(info->getServiceName(), dataOut, bs); tightMarshalString2(info->getBrokerName(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -135,10 +132,9 @@ void DiscoveryEventMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setServiceName(looseUnmarshalString(dataIn)); info->setBrokerName(looseUnmarshalString(dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -155,8 +151,7 @@ void DiscoveryEventMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalString(info->getServiceName(), dataOut); looseMarshalString(info->getBrokerName(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.h index d8e9212da..360003eba 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.cpp index 7c8c3d2da..ad3fcfd88 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.cpp @@ -71,10 +71,9 @@ void ExceptionResponseMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalBrokerError(wireFormat, dataIn, bs)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -95,10 +94,9 @@ int ExceptionResponseMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -121,10 +119,9 @@ void ExceptionResponseMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -141,10 +138,9 @@ void ExceptionResponseMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalBrokerError(wireFormat, dataIn)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -161,8 +157,7 @@ void ExceptionResponseMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getException().get(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.h index e3cc3cbac..2f3aa72bc 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.cpp index dedbc6d63..25c380525 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.cpp @@ -65,10 +65,9 @@ void FlushCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -83,10 +82,9 @@ int FlushCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -102,10 +100,9 @@ void FlushCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -119,10 +116,9 @@ void FlushCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -134,8 +130,7 @@ void FlushCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, { BaseCommandMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.h index 7a024e25f..e88bd33cb 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.cpp index 7d2d145df..ff3697b81 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.cpp @@ -68,10 +68,9 @@ void IntegerResponseMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, IntegerResponse* info = dynamic_cast(dataStructure); info->setResult(dataIn->readInt()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -86,10 +85,9 @@ int IntegerResponseMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -108,10 +106,9 @@ void IntegerResponseMarshaller::tightMarshal2(OpenWireFormat* wireFormat, IntegerResponse* info = dynamic_cast(dataStructure); dataOut->writeInt(info->getResult()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -125,10 +122,9 @@ void IntegerResponseMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, IntegerResponse* info = dynamic_cast(dataStructure); info->setResult(dataIn->readInt()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -142,8 +138,7 @@ void IntegerResponseMarshaller::looseMarshal(OpenWireFormat* wireFormat, ResponseMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); dataOut->writeInt(info->getResult()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.h index 83189e550..249614c16 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.cpp index fc1ef2593..ca9ea2c44 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.cpp @@ -73,10 +73,9 @@ void JournalQueueAckMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -100,10 +99,9 @@ int JournalQueueAckMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -129,10 +127,9 @@ void JournalQueueAckMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -153,10 +150,9 @@ void JournalQueueAckMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalNestedObject(wireFormat, dataIn)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -177,8 +173,7 @@ void JournalQueueAckMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getMessageAck().get(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.h index c416d3f00..31c29b921 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.cpp index 912f0efa3..a3a3a1178 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.cpp @@ -78,10 +78,9 @@ void JournalTopicAckMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -111,10 +110,9 @@ int JournalTopicAckMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -147,10 +145,9 @@ void JournalTopicAckMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -176,10 +173,9 @@ void JournalTopicAckMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalNestedObject(wireFormat, dataIn)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -206,8 +202,7 @@ void JournalTopicAckMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getTransactionId().get(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.h index e1b1a31ca..db0f760cf 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.cpp index 1b9a804c8..3828c6596 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.cpp @@ -68,10 +68,9 @@ void JournalTraceMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, JournalTrace* info = dynamic_cast(dataStructure); info->setMessage(tightUnmarshalString(dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -90,10 +89,9 @@ int JournalTraceMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -112,10 +110,9 @@ void JournalTraceMarshaller::tightMarshal2(OpenWireFormat* wireFormat, JournalTrace* info = dynamic_cast(dataStructure); tightMarshalString2(info->getMessage(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -131,10 +128,9 @@ void JournalTraceMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, JournalTrace* info = dynamic_cast(dataStructure); info->setMessage(looseUnmarshalString(dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -150,8 +146,7 @@ void JournalTraceMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); looseMarshalString(info->getMessage(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.h index 02a214a71..3f6518dea 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.cpp index a677552b4..60e319348 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.cpp @@ -73,10 +73,9 @@ void JournalTransactionMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setType(dataIn->readByte()); info->setWasPrepared(bs->readBoolean()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -99,10 +98,9 @@ int JournalTransactionMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 1; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -127,10 +125,9 @@ void JournalTransactionMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->write(info->getType()); bs->readBoolean(); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -151,10 +148,9 @@ void JournalTransactionMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setType(dataIn->readByte()); info->setWasPrepared(dataIn->readBoolean()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -175,8 +171,7 @@ void JournalTransactionMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->write(info->getType()); dataOut->writeBoolean(info->getWasPrepared()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.h index 766270ef1..f1d9208b0 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.cpp index 43cc26de3..e466fd10a 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.cpp @@ -65,10 +65,9 @@ void KeepAliveInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -83,10 +82,9 @@ int KeepAliveInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -102,10 +100,9 @@ void KeepAliveInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -119,10 +116,9 @@ void KeepAliveInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -134,8 +130,7 @@ void KeepAliveInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, { BaseCommandMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.h index 8fb9c936b..6a5f2e4f0 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.cpp index 98622460b..e19ccdb06 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.cpp @@ -65,10 +65,9 @@ void LastPartialCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -84,10 +83,9 @@ int LastPartialCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -103,10 +101,9 @@ void LastPartialCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -120,10 +117,9 @@ void LastPartialCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -137,8 +133,7 @@ void LastPartialCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.h index 2e54b867f..9aa403077 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.cpp index 2c56dcb97..e239384f0 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.cpp @@ -72,10 +72,9 @@ void LocalTransactionIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalCachedObject(wireFormat, dataIn, bs)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -98,10 +97,9 @@ int LocalTransactionIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -125,10 +123,9 @@ void LocalTransactionIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -148,10 +145,9 @@ void LocalTransactionIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalCachedObject(wireFormat, dataIn)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -171,8 +167,7 @@ void LocalTransactionIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getConnectionId().get(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.h index 579562950..632a13643 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.cpp index 99376d10c..4da2e5ad3 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.cpp @@ -93,10 +93,9 @@ void MessageAckMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, tightUnmarshalBrokerError(wireFormat, dataIn, bs)))); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -137,10 +136,9 @@ int MessageAckMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 5; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -190,10 +188,9 @@ void MessageAckMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -234,10 +231,9 @@ void MessageAckMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, looseUnmarshalBrokerError(wireFormat, dataIn)))); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -276,8 +272,7 @@ void MessageAckMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.h index df7b07094..b604e3d25 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.cpp index 3a0d406f8..74a4229da 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.cpp @@ -79,10 +79,9 @@ void MessageDispatchMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); info->setRedeliveryCounter(dataIn->readInt()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -107,10 +106,9 @@ int MessageDispatchMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -141,10 +139,9 @@ void MessageDispatchMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); dataOut->writeInt(info->getRedeliveryCounter()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -168,10 +165,9 @@ void MessageDispatchMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, looseUnmarshalNestedObject(wireFormat, dataIn)))); info->setRedeliveryCounter(dataIn->readInt()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -192,8 +188,7 @@ void MessageDispatchMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalNestedObject(wireFormat, info->getMessage().get(), dataOut); dataOut->writeInt(info->getRedeliveryCounter()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.h index cefca861f..dbdb25682 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.cpp index 0090e7083..65b835d9c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.cpp @@ -78,10 +78,9 @@ void MessageDispatchNotificationMarshaller::tightUnmarshal( info->setMessageId(std::shared_ptr(dynamic_cast( tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -110,10 +109,9 @@ int MessageDispatchNotificationMarshaller::tightMarshal1( return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -149,10 +147,9 @@ void MessageDispatchNotificationMarshaller::tightMarshal2( dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -178,10 +175,9 @@ void MessageDispatchNotificationMarshaller::looseUnmarshal( info->setMessageId(std::shared_ptr(dynamic_cast( looseUnmarshalNestedObject(wireFormat, dataIn)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -206,8 +202,7 @@ void MessageDispatchNotificationMarshaller::looseMarshal( info->getMessageId().get(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.h index a30d5c503..f91f260b2 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.cpp index e174ebd60..b9a7c9556 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.cpp @@ -79,10 +79,9 @@ void MessageIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setProducerSequenceId(tightUnmarshalLong(wireFormat, dataIn, bs)); info->setBrokerSequenceId(tightUnmarshalLong(wireFormat, dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -112,10 +111,9 @@ int MessageIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -149,10 +147,9 @@ void MessageIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); tightMarshalLong2(wireFormat, info->getBrokerSequenceId(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -179,10 +176,9 @@ void MessageIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setProducerSequenceId(looseUnmarshalLong(wireFormat, dataIn)); info->setBrokerSequenceId(looseUnmarshalLong(wireFormat, dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -209,8 +205,7 @@ void MessageIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalLong(wireFormat, info->getProducerSequenceId(), dataOut); looseMarshalLong(wireFormat, info->getBrokerSequenceId(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.h index 8248bb380..69e487db5 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.cpp index 600b8ae9a..a94aad4cc 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.cpp @@ -152,10 +152,9 @@ void MessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setJMSXGroupFirstForConsumer(bs->readBoolean()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -240,10 +239,9 @@ int MessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 9; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -354,10 +352,9 @@ void MessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs->readBoolean(); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -466,10 +463,9 @@ void MessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setJMSXGroupFirstForConsumer(dataIn->readBoolean()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -563,8 +559,7 @@ void MessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeBoolean(info->isJMSXGroupFirstForConsumer()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.h index d79804e11..85d38a3f3 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.cpp index 62c9322d0..831234392 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.cpp @@ -87,10 +87,9 @@ void MessagePullMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -127,10 +126,9 @@ int MessagePullMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -171,10 +169,9 @@ void MessagePullMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -209,10 +206,9 @@ void MessagePullMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, looseUnmarshalNestedObject(wireFormat, dataIn)))); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -245,8 +241,7 @@ void MessagePullMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.h index 169d677a7..b387e3294 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.cpp index f0ae092d3..ad83ea953 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.cpp @@ -82,10 +82,9 @@ void NetworkBridgeFilterMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setConsumerTTL(dataIn->readInt()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -116,10 +115,9 @@ int NetworkBridgeFilterMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 8; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -153,10 +151,9 @@ void NetworkBridgeFilterMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->writeInt(info->getConsumerTTL()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -186,10 +183,9 @@ void NetworkBridgeFilterMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setConsumerTTL(dataIn->readInt()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -219,8 +215,7 @@ void NetworkBridgeFilterMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeInt(info->getConsumerTTL()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.h index c340eb6c4..d422dd735 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.cpp index 1dde8e90e..d802bc5ce 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.cpp @@ -69,10 +69,9 @@ void PartialCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setCommandId(dataIn->readInt()); info->setData(tightUnmarshalByteArray(dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -92,10 +91,9 @@ int PartialCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -122,10 +120,9 @@ void PartialCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, (int)info->getData().size()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -142,10 +139,9 @@ void PartialCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setCommandId(dataIn->readInt()); info->setData(looseUnmarshalByteArray(dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -170,8 +166,7 @@ void PartialCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, (int)info->getData().size()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.h index b5acfec8d..9ad43c1a9 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.cpp index b9a01e313..dafcd181f 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.cpp @@ -80,10 +80,9 @@ void ProducerAckMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setSize(dataIn->readInt()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -112,10 +111,9 @@ int ProducerAckMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -147,10 +145,9 @@ void ProducerAckMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->writeInt(info->getSize()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -178,10 +175,9 @@ void ProducerAckMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setSize(dataIn->readInt()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -207,8 +203,7 @@ void ProducerAckMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeInt(info->getSize()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.h index 47ee31485..003d94981 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.cpp index 1e9bcfe66..5a2bbe0f4 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.cpp @@ -70,10 +70,9 @@ void ProducerIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setValue(tightUnmarshalLong(wireFormat, dataIn, bs)); info->setSessionId(tightUnmarshalLong(wireFormat, dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -94,10 +93,9 @@ int ProducerIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -118,10 +116,9 @@ void ProducerIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalLong2(wireFormat, info->getValue(), dataOut, bs); tightMarshalLong2(wireFormat, info->getSessionId(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -139,10 +136,9 @@ void ProducerIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setValue(looseUnmarshalLong(wireFormat, dataIn)); info->setSessionId(looseUnmarshalLong(wireFormat, dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -160,8 +156,7 @@ void ProducerIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalLong(wireFormat, info->getValue(), dataOut); looseMarshalLong(wireFormat, info->getSessionId(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.h index 3b5de5ee5..645f333ca 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.cpp index b6de21ec9..4dc05f43e 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.cpp @@ -100,10 +100,9 @@ void ProducerInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setWindowSize(dataIn->readInt()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -137,10 +136,9 @@ int ProducerInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -178,10 +176,9 @@ void ProducerInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->writeInt(info->getWindowSize()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -229,10 +226,9 @@ void ProducerInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setWindowSize(dataIn->readInt()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -263,8 +259,7 @@ void ProducerInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeInt(info->getWindowSize()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.h index 201038361..320a72ea8 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.cpp index 9dfbbd1e9..f098bbfd6 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.cpp @@ -78,10 +78,9 @@ void RemoveInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, tightUnmarshalLong(wireFormat, dataIn, bs)); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -110,10 +109,9 @@ int RemoveInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -145,10 +143,9 @@ void RemoveInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -174,10 +171,9 @@ void RemoveInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, looseUnmarshalLong(wireFormat, dataIn)); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -202,8 +198,7 @@ void RemoveInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.h index 20d27463c..f898005c6 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.cpp index 522a6fcb8..8eb06e764 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.cpp @@ -74,10 +74,9 @@ void RemoveSubscriptionInfoMarshaller::tightUnmarshal( info->setSubcriptionName(tightUnmarshalString(dataIn, bs)); info->setClientId(tightUnmarshalString(dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -100,10 +99,9 @@ int RemoveSubscriptionInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -129,10 +127,9 @@ void RemoveSubscriptionInfoMarshaller::tightMarshal2( tightMarshalString2(info->getSubcriptionName(), dataOut, bs); tightMarshalString2(info->getClientId(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -154,10 +151,9 @@ void RemoveSubscriptionInfoMarshaller::looseUnmarshal( info->setSubcriptionName(looseUnmarshalString(dataIn)); info->setClientId(looseUnmarshalString(dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -176,8 +172,7 @@ void RemoveSubscriptionInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalString(info->getSubcriptionName(), dataOut); looseMarshalString(info->getClientId(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.h index bb3e165c0..122d3a343 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.cpp index 33a5d7b75..da2d653bc 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.cpp @@ -69,10 +69,9 @@ void ReplayCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setFirstNakNumber(dataIn->readInt()); info->setLastNakNumber(dataIn->readInt()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -87,10 +86,9 @@ int ReplayCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 8; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -110,10 +108,9 @@ void ReplayCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->writeInt(info->getFirstNakNumber()); dataOut->writeInt(info->getLastNakNumber()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -130,10 +127,9 @@ void ReplayCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setFirstNakNumber(dataIn->readInt()); info->setLastNakNumber(dataIn->readInt()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -148,8 +144,7 @@ void ReplayCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeInt(info->getFirstNakNumber()); dataOut->writeInt(info->getLastNakNumber()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.h index 72ac6d38a..e1f1eddbb 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.cpp index 99700f629..d98a8f6b6 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.cpp @@ -68,10 +68,9 @@ void ResponseMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, Response* info = dynamic_cast(dataStructure); info->setCorrelationId(dataIn->readInt()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -86,10 +85,9 @@ int ResponseMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -108,10 +106,9 @@ void ResponseMarshaller::tightMarshal2(OpenWireFormat* wireFormat, Response* info = dynamic_cast(dataStructure); dataOut->writeInt(info->getCorrelationId()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -127,10 +124,9 @@ void ResponseMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, Response* info = dynamic_cast(dataStructure); info->setCorrelationId(dataIn->readInt()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -144,8 +140,7 @@ void ResponseMarshaller::looseMarshal(OpenWireFormat* wireFormat, BaseCommandMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); dataOut->writeInt(info->getCorrelationId()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.h index f9c9e7338..7f3b5d721 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.cpp index 2e5912ccf..574c53062 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.cpp @@ -69,10 +69,9 @@ void SessionIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setConnectionId(tightUnmarshalString(dataIn, bs)); info->setValue(tightUnmarshalLong(wireFormat, dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -92,10 +91,9 @@ int SessionIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -115,10 +113,9 @@ void SessionIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalString2(info->getConnectionId(), dataOut, bs); tightMarshalLong2(wireFormat, info->getValue(), dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -135,10 +132,9 @@ void SessionIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setConnectionId(looseUnmarshalString(dataIn)); info->setValue(looseUnmarshalLong(wireFormat, dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -155,8 +151,7 @@ void SessionIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalString(info->getConnectionId(), dataOut); looseMarshalLong(wireFormat, info->getValue(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.h index b9c86415b..56ad57e3d 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.cpp index 695836206..6bb1fcc12 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.cpp @@ -69,10 +69,9 @@ void SessionInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setSessionId(std::shared_ptr(dynamic_cast( tightUnmarshalCachedObject(wireFormat, dataIn, bs)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -92,10 +91,9 @@ int SessionInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -117,10 +115,9 @@ void SessionInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -137,10 +134,9 @@ void SessionInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setSessionId(std::shared_ptr(dynamic_cast( looseUnmarshalCachedObject(wireFormat, dataIn)))); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -156,8 +152,7 @@ void SessionInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getSessionId().get(), dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.h index 1bb348724..625b875b7 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.cpp index 07833b6ed..560aa0ad8 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.cpp @@ -65,10 +65,9 @@ void ShutdownInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -83,10 +82,9 @@ int ShutdownInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -102,10 +100,9 @@ void ShutdownInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -119,10 +116,9 @@ void ShutdownInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -134,8 +130,7 @@ void ShutdownInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, { BaseCommandMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.h index cfc28f597..6182a505f 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.cpp index 8ad1bd738..62c5cd8b2 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.cpp @@ -86,10 +86,9 @@ void SubscriptionInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setNoLocal(bs->readBoolean()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -127,10 +126,9 @@ int SubscriptionInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -169,10 +167,9 @@ void SubscriptionInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs->readBoolean(); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -206,10 +203,9 @@ void SubscriptionInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setNoLocal(dataIn->readBoolean()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -243,8 +239,7 @@ void SubscriptionInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeBoolean(info->isNoLocal()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.h index 2f9004861..65da0e893 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.cpp index 1cf1fbb00..e0034ac83 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.cpp @@ -53,10 +53,9 @@ void TransactionIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -72,10 +71,9 @@ int TransactionIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -91,10 +89,9 @@ void TransactionIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -108,10 +105,9 @@ void TransactionIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -125,8 +121,7 @@ void TransactionIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.h index 9b3d81be0..8689e3d9b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.cpp index f52af43c5..d6a2f965b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.cpp @@ -74,10 +74,9 @@ void TransactionInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, tightUnmarshalCachedObject(wireFormat, dataIn, bs)))); info->setType(dataIn->readByte()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -100,10 +99,9 @@ int TransactionInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 1; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -130,10 +128,9 @@ void TransactionInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); dataOut->write(info->getType()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -155,10 +152,9 @@ void TransactionInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, looseUnmarshalCachedObject(wireFormat, dataIn)))); info->setType(dataIn->readByte()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -178,8 +174,7 @@ void TransactionInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); dataOut->write(info->getType()); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.h index 72f68e0d9..8bb346f7b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.cpp index 528375f97..8f71d9777 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.cpp @@ -74,10 +74,9 @@ void WireFormatInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -100,10 +99,9 @@ int WireFormatInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 12; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -133,10 +131,9 @@ void WireFormatInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, } info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -156,10 +153,9 @@ void WireFormatInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setMarshalledProperties(looseUnmarshalByteArray(dataIn)); info->afterUnmarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -188,8 +184,7 @@ void WireFormatInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, } info->afterMarshal(wireFormat); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.h index f1cb08eb1..c4ecd8724 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.cpp index 983040127..d7db7e946 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.cpp @@ -70,10 +70,9 @@ void XATransactionIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs)); info->setBranchQualifier(tightUnmarshalByteArray(dataIn, bs)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -99,10 +98,9 @@ int XATransactionIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -139,10 +137,9 @@ void XATransactionIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, (int)info->getBranchQualifier().size()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -160,10 +157,9 @@ void XATransactionIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setGlobalTransactionId(looseUnmarshalByteArray(dataIn)); info->setBranchQualifier(looseUnmarshalByteArray(dataIn)); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } /////////////////////////////////////////////////////////////////////////////// @@ -199,8 +195,7 @@ void XATransactionIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, (int)info->getBranchQualifier().size()); } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException, - decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.h index 4b8bd2296..ca8a1c847 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.h @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace activemq { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/utils/BooleanStream.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/utils/BooleanStream.cpp index b06d8427a..1df2e0f4a 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/utils/BooleanStream.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/utils/BooleanStream.cpp @@ -27,7 +27,6 @@ using namespace activemq::wireformat::openwire; using namespace activemq::wireformat::openwire::utils; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; /////////////////////////////////////////////////////////////////////////////// BooleanStream::BooleanStream() @@ -60,9 +59,9 @@ bool BooleanStream::readBoolean() } return rc; } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -95,9 +94,9 @@ void BooleanStream::writeBoolean(bool value) arrayPos++; } } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -124,9 +123,9 @@ void BooleanStream::marshal(DataOutputStream* dataOut) dataOut->write(&data[0], (int)data.size(), 0, arrayLimit); clear(); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -153,9 +152,9 @@ void BooleanStream::marshal(std::vector& dataOut) // Insert all data from data into the passed buffer dataOut.insert(dataOut.end(), &data[0], &data[arrayLimit - 1]); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -182,9 +181,9 @@ void BooleanStream::unmarshal(DataInputStream* dataIn) clear(); } - AMQ_CATCH_RETHROW(IOException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IOException) - AMQ_CATCHALL_THROW(IOException) + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(Exception, activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/utils/HexTable.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/utils/HexTable.cpp index 7065ab7bb..62f4bdd47 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/utils/HexTable.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/utils/HexTable.cpp @@ -18,6 +18,8 @@ #include "HexTable.h" #include +#include +#include #include using namespace std; @@ -26,8 +28,6 @@ using namespace activemq::exceptions; using namespace activemq::wireformat; using namespace activemq::wireformat::openwire; using namespace activemq::wireformat::openwire::utils; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// HexTable::HexTable() @@ -65,45 +65,27 @@ HexTable::HexTable() //////////////////////////////////////////////////////////////////////////////// const std::string& HexTable::operator[](std::size_t index) { - try + if (size() < index) { - if (size() < index) - { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - (string("HexTable::operator[] - Index passed is out of " - "Bounds") + - std::to_string((int)index)) - .c_str()); - } - - return table[index]; + throw activemq::exceptions::IndexOutOfBoundsException( + "HexTable::operator[] - Index passed is out of " + "Bounds" + + std::to_string((int)index)); } - AMQ_CATCH_RETHROW(IndexOutOfBoundsException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - AMQ_CATCHALL_THROW(IndexOutOfBoundsException) + + return table[index]; } //////////////////////////////////////////////////////////////////////////////// const std::string& HexTable::operator[](std::size_t index) const { - try + if (size() < index) { - if (size() < index) - { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - (string("HexTable::operator[] - Index passed is out of " - "Bounds") + - std::to_string((int)index)) - .c_str()); - } - - return table[index]; + throw activemq::exceptions::IndexOutOfBoundsException( + "HexTable::operator[] - Index passed is out of " + "Bounds" + + std::to_string((int)index)); } - AMQ_CATCH_RETHROW(IndexOutOfBoundsException) - AMQ_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - AMQ_CATCHALL_THROW(IndexOutOfBoundsException) + + return table[index]; } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/utils/HexTable.h b/activemq-cpp/src/main/activemq/wireformat/openwire/utils/HexTable.h index 61e4c3484..4554aafd3 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/utils/HexTable.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/utils/HexTable.h @@ -22,7 +22,6 @@ #include #include -#include namespace activemq { @@ -60,7 +59,7 @@ namespace wireformat * * @return string containing the hex value if the index * - * @throws IndexOutOfBoundsException if the index exceeds the + * @throws std::out_of_range if the index exceeds the * table size. */ virtual const std::string& operator[](std::size_t index); diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.cpp index 6d88e69e0..753a8eb4b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.cpp @@ -22,6 +22,10 @@ #include #include +#include +#include +#include + using namespace std; using namespace activemq; using namespace activemq::util; @@ -31,7 +35,6 @@ using namespace activemq::wireformat::openwire; using namespace activemq::wireformat::openwire::utils; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// MessagePropertyInterceptor::MessagePropertyInterceptor( @@ -42,16 +45,18 @@ MessagePropertyInterceptor::MessagePropertyInterceptor( { if (message == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Message passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Message passed was NULL"); } if (properties == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "PrimitiveMap passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "PrimitiveMap passed was NULL"); } } @@ -365,11 +370,31 @@ void MessagePropertyInterceptor::setStringProperty(const std::string& name, } else if (name == "JMSXDeliveryCount") { - this->message->setRedeliveryCounter(Integer::parseInt(value)); + try + { + this->message->setRedeliveryCounter(Integer::parseInt(value)); + } + catch (std::exception&) + { + throw ActiveMQException( + __FILE__, + __LINE__, + "Cannot Convert Reserved Property to this Type."); + } } else if (name == "JMSXGroupSeq") { - this->message->setGroupSequence(Integer::parseInt(value)); + try + { + this->message->setGroupSequence(Integer::parseInt(value)); + } + catch (std::exception&) + { + throw ActiveMQException( + __FILE__, + __LINE__, + "Cannot Convert Reserved Property to this Type."); + } } else if (name == "JMSXGroupFirstForConsumer") { diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.h b/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.h index 9a887003b..45aac670b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.h @@ -23,8 +23,6 @@ #include #include -#include - namespace activemq { namespace wireformat @@ -72,7 +70,7 @@ namespace wireformat * @param properties - The PrimitiveMap to store the rest of the * properties in. * - * @throws NullPointerException if either param is NULL + * @throws std::logic_error if either param is NULL */ MessagePropertyInterceptor(commands::Message* message, util::PrimitiveMap* properties); diff --git a/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.cpp b/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.cpp index cdc583f60..22b131918 100644 --- a/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.cpp @@ -22,7 +22,6 @@ using namespace std; using namespace activemq; using namespace activemq::wireformat; using namespace activemq::wireformat::stomp; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// // Stomp Command Ids diff --git a/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.h b/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.h index 61631c958..cc6b24065 100644 --- a/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.h +++ b/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.h @@ -19,7 +19,6 @@ #include #include -#include #include #include diff --git a/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp b/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp index c4f5071a3..d86b08dc1 100644 --- a/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp @@ -19,10 +19,14 @@ #include +#include + #include -#include #include +#include +#include +#include #include using namespace std; @@ -31,9 +35,7 @@ using namespace activemq::exceptions; using namespace activemq::wireformat; using namespace activemq::wireformat::stomp; using namespace decaf; -using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// StompFrame::StompFrame() @@ -80,7 +82,10 @@ void StompFrame::toStream(decaf::io::DataOutputStream* stream) const { if (stream == NULL) { - throw NullPointerException(__FILE__, __LINE__, "Stream Passed is Null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Stream Passed is Null"); } // Write the command. @@ -137,9 +142,10 @@ void StompFrame::fromStream(decaf::io::DataInputStream* in) { if (in == NULL) { - throw decaf::io::IOException(__FILE__, - __LINE__, - "DataInputStream passed is NULL"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "DataInputStream passed is NULL"); } try @@ -153,9 +159,9 @@ void StompFrame::fromStream(decaf::io::DataInputStream* in) // Read the body. readBody(in); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -191,9 +197,9 @@ void StompFrame::readCommandHeader(decaf::io::DataInputStream* in) } } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -213,7 +219,7 @@ void StompFrame::readHeaders(decaf::io::DataInputStream* in) if (numChars == 0) { // should never get here - throw decaf::io::IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "StompWireFormat::readStompHeaders: no characters read"); @@ -253,9 +259,9 @@ void StompFrame::readHeaders(decaf::io::DataInputStream* in) } } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -288,14 +294,15 @@ std::size_t StompFrame::readHeaderLine(std::vector& buffer, } // If we get here something bad must have happened. - throw decaf::io::IOException(__FILE__, - __LINE__, - "StompWireFormat::readStompHeaderLine: " - "Unrecoverable, error condition"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "StompWireFormat::readStompHeaderLine: " + "Unrecoverable, error condition"); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -339,7 +346,7 @@ void StompFrame::readBody(decaf::io::DataInputStream* in) // Content Length read, now pop the end terminator off (\0\n). if (in->readByte() != '\0') { - throw decaf::io::IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "StompWireFormat::readStompBody: " @@ -364,7 +371,7 @@ void StompFrame::readBody(decaf::io::DataInputStream* in) } } } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } diff --git a/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp b/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp index b676266ba..d855bf06d 100644 --- a/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp @@ -39,13 +39,19 @@ #include #include +#include + +#include +#include +#include #include +#include #include -#include #include #include -#include #include +#include +#include using namespace std; using namespace activemq; @@ -53,10 +59,9 @@ using namespace activemq::commands; using namespace activemq::core; using namespace activemq::wireformat; using namespace activemq::wireformat::stomp; +using namespace activemq::exceptions; using namespace decaf; -using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace activemq @@ -129,10 +134,11 @@ void StompWireFormat::marshal(const std::shared_ptr command, { if (out == NULL) { - throw decaf::io::IOException(__FILE__, - __LINE__, - "StompCommandWriter::writeCommand - " - "output stream is NULL"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "StompCommandWriter::writeCommand - " + "output stream is NULL"); } std::shared_ptr frame; @@ -193,9 +199,9 @@ void StompWireFormat::marshal(const std::shared_ptr command, // Let the Frame write itself to the output stream frame->toStream(out); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// @@ -205,16 +211,17 @@ std::shared_ptr StompWireFormat::unmarshal( { if (transport == NULL) { - throw decaf::io::IOException(__FILE__, - __LINE__, - "Transport passed is NULL"); + throw activemq::exceptions::IOException(__FILE__, + __LINE__, + "Transport passed is NULL"); } if (in == NULL) { - throw decaf::io::IOException(__FILE__, - __LINE__, - "DataInputStream passed is NULL"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "DataInputStream passed is NULL"); } std::shared_ptr frame; @@ -270,21 +277,21 @@ std::shared_ptr StompWireFormat::unmarshal( } // We didn't seem to know what it was we got, so throw an exception. - throw decaf::io::IOException( + throw activemq::exceptions::IOException( __FILE__, __LINE__, "StompWireFormat::marshal - No Command Created from frame"); } - AMQ_CATCH_RETHROW(decaf::io::IOException) - AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, decaf::io::IOException) - AMQ_CATCHALL_THROW(decaf::io::IOException) + AMQ_IOSTREAM_CATCH_RETHROW() + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + AMQ_IOSTREAM_CATCHALL_THROW() } //////////////////////////////////////////////////////////////////////////////// std::shared_ptr StompWireFormat::createNegotiator( const std::shared_ptr transport AMQCPP_UNUSED) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "No Negotiator is required to use this WireFormat."); @@ -346,9 +353,10 @@ std::shared_ptr StompWireFormat::unmarshalReceipt( } else { - throw IOException(__FILE__, - __LINE__, - "Error, Connected Command has no Response ID."); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "Error, Connected Command has no Response ID."); } return response; @@ -366,9 +374,10 @@ std::shared_ptr StompWireFormat::unmarshalConnected( } else { - throw IOException(__FILE__, - __LINE__, - "Error, Connected Command has no Response ID."); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "Error, Connected Command has no Response ID."); } return response; @@ -430,22 +439,19 @@ std::shared_ptr StompWireFormat::marshalMessage( helper->convertProperties(message, frame); // Convert the Content - try + std::shared_ptr txtMessage = + std::dynamic_pointer_cast(message); + if (txtMessage) { - std::shared_ptr txtMessage = - std::dynamic_pointer_cast(message); std::string text = txtMessage->getText(); frame->setBody((unsigned char*)text.c_str(), text.length() + 1); return frame; } - catch (ClassCastException& ex) - { - } - try + std::shared_ptr bytesMessage = + std::dynamic_pointer_cast(message); + if (bytesMessage) { - std::shared_ptr bytesMessage = - std::dynamic_pointer_cast(message); unsigned char* bodyBytes = bytesMessage->getBodyBytes(); frame->setBody(bodyBytes, bytesMessage->getBodyLength()); frame->setProperty(StompCommandConstants::HEADER_CONTENTLENGTH, @@ -456,15 +462,12 @@ std::shared_ptr StompWireFormat::marshalMessage( } return frame; } - catch (ClassCastException& ex) - { - } - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, - "Stomp StompWireFormat can't marshal message of type: %s", - typeid(message.get()).name()); + std::string("Stomp StompWireFormat can't marshal message of type: ") + + typeid(message.get()).name()); } //////////////////////////////////////////////////////////////////////////////// @@ -589,17 +592,14 @@ std::shared_ptr StompWireFormat::marshalRemoveInfo( std::to_string(command->getCommandId())); } - try + std::shared_ptr id = + std::dynamic_pointer_cast(info->getObjectId()); + if (id) { - std::shared_ptr id = - std::dynamic_pointer_cast(info->getObjectId()); frame->setProperty(StompCommandConstants::HEADER_ID, helper->convertConsumerId(id)); return frame; } - catch (ClassCastException& ex) - { - } return std::shared_ptr(); } @@ -633,14 +633,14 @@ std::shared_ptr StompWireFormat::marshalConsumerInfo( { if (this->clientId != info->getSubscriptionName()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, - "Stomp Durable Subscriptions require that the ClientId and the " - "Subscription " - "Name match, clientId = {%s} : subscription name = {%s}.", - this->clientId.c_str(), - info->getSubscriptionName().c_str()); + std::string("Stomp Durable Subscriptions require that the " + "ClientId and the Subscription Name match, " + "clientId = {") + + this->clientId + "} : subscription name = {" + + info->getSubscriptionName() + "}."); } frame->setProperty(StompCommandConstants::HEADER_SUBSCRIPTIONNAME, diff --git a/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h b/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h index ed6ca00f9..c15a3e54c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h +++ b/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h @@ -18,12 +18,13 @@ #ifndef _ACTIVEMQ_WIREFORMAT_STOMP_STOMPWIREFORMAT_H_ #define _ACTIVEMQ_WIREFORMAT_STOMP_STOMPWIREFORMAT_H_ +#include #include #include #include -#include #include #include +#include namespace activemq { @@ -201,7 +202,7 @@ namespace wireformat * If the Transport Provides a Negotiator this method will create * and return a news instance of the Negotiator. * @return new instance of a WireFormatNegotiator. - * @throws UnsupportedOperationException if the WireFormat doesn't + * @throws std::logic_error if the WireFormat doesn't * have a Negotiator. */ virtual std::shared_ptr createNegotiator( diff --git a/activemq-cpp/src/main/cms/BytesMessage.h b/activemq-cpp/src/main/cms/BytesMessage.h index 4e7163de2..ccaad4584 100644 --- a/activemq-cpp/src/main/cms/BytesMessage.h +++ b/activemq-cpp/src/main/cms/BytesMessage.h @@ -232,7 +232,7 @@ class CMS_API BytesMessage : public Message * be read from the stream. The next read of the stream returns -1. * * If length is negative, or length is greater than the length of the - * array value, then an IndexOutOfBoundsException is thrown. No bytes + * array value, then std::out_of_range is thrown. No bytes * will be read from the stream for this exception case. * * @param buffer diff --git a/activemq-cpp/src/main/cms/XAConnectionFactory.h b/activemq-cpp/src/main/cms/XAConnectionFactory.h index 639d52b99..ea8f8e8c2 100644 --- a/activemq-cpp/src/main/cms/XAConnectionFactory.h +++ b/activemq-cpp/src/main/cms/XAConnectionFactory.h @@ -22,6 +22,7 @@ #include #include +#include namespace cms { diff --git a/activemq-cpp/src/main/decaf/internal/io/StandardErrorOutputStream.cpp b/activemq-cpp/src/main/decaf/internal/io/StandardErrorOutputStream.cpp index b1d5b104a..c1144f389 100644 --- a/activemq-cpp/src/main/decaf/internal/io/StandardErrorOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/internal/io/StandardErrorOutputStream.cpp @@ -17,9 +17,11 @@ #include "StandardErrorOutputStream.h" +#include +#include + using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::io; @@ -52,34 +54,29 @@ void StandardErrorOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (buffer == NULL) { - throw lang::exceptions::NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "StandardErrorOutputStream::write - Passed buffer is null."); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + "."); } for (int i = 0; i < length; ++i) diff --git a/activemq-cpp/src/main/decaf/internal/io/StandardInputStream.cpp b/activemq-cpp/src/main/decaf/internal/io/StandardInputStream.cpp index f4d7a8f29..42b993e3e 100644 --- a/activemq-cpp/src/main/decaf/internal/io/StandardInputStream.cpp +++ b/activemq-cpp/src/main/decaf/internal/io/StandardInputStream.cpp @@ -22,7 +22,6 @@ using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::io; diff --git a/activemq-cpp/src/main/decaf/internal/io/StandardOutputStream.cpp b/activemq-cpp/src/main/decaf/internal/io/StandardOutputStream.cpp index 8e5e4fa86..7ae3422d6 100644 --- a/activemq-cpp/src/main/decaf/internal/io/StandardOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/internal/io/StandardOutputStream.cpp @@ -17,9 +17,11 @@ #include "StandardOutputStream.h" +#include +#include + using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::io; @@ -52,7 +54,7 @@ void StandardOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (buffer == NULL) { - throw lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "StandardErrorOutputStream::write - Passed buffer is null."); @@ -60,26 +62,23 @@ void StandardOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + "."); } for (int i = 0; i < length; ++i) diff --git a/activemq-cpp/src/main/decaf/internal/net/Network.cpp b/activemq-cpp/src/main/decaf/internal/net/Network.cpp index 0b38336e2..82b4976e9 100644 --- a/activemq-cpp/src/main/decaf/internal/net/Network.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/Network.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include @@ -28,12 +27,15 @@ #include #endif +#include +#include +#include + using namespace decaf; using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::internal::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -123,9 +125,10 @@ Network* Network::getNetworkRuntime() { if (Network::networkRuntime == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "Network Runtime is not Initialized."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Network Runtime is not Initialized."); } return Network::networkRuntime; diff --git a/activemq-cpp/src/main/decaf/internal/net/Network.h b/activemq-cpp/src/main/decaf/internal/net/Network.h index 5b7cd91b4..1760850c1 100644 --- a/activemq-cpp/src/main/decaf/internal/net/Network.h +++ b/activemq-cpp/src/main/decaf/internal/net/Network.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace decaf { @@ -77,7 +78,7 @@ namespace internal * @param value * The Resource to add to the Network Runtime. * - * @throw NullPointerException if the Resource value passed is null. + * @throw std::logic_error if the Resource value passed is null. */ void addNetworkResource(decaf::internal::util::Resource* value); @@ -114,7 +115,7 @@ namespace internal /** * Gets the one and only instance of the Network class, if this is * called before the Network layer has been initialized or after it - * has been shutdown then an IllegalStateException is thrown. + * has been shutdown then std::logic_error is thrown. * * @return pointer to the Network runtime for the Decaf library. */ diff --git a/activemq-cpp/src/main/decaf/internal/net/URIEncoderDecoder.cpp b/activemq-cpp/src/main/decaf/internal/net/URIEncoderDecoder.cpp index ca2892426..02395b9b2 100644 --- a/activemq-cpp/src/main/decaf/internal/net/URIEncoderDecoder.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/URIEncoderDecoder.cpp @@ -18,11 +18,13 @@ #include "URIEncoderDecoder.h" #include -#include + +#include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::net; @@ -172,11 +174,9 @@ std::string URIEncoderDecoder::decode(const std::string& s) { if (i + 2 >= s.length()) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "String has invalid encoding: %s", - s.c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": String has invalid encoding: " + s); } int d1 = Character::digit(s.at(i + 1), 16); @@ -184,11 +184,10 @@ std::string URIEncoderDecoder::decode(const std::string& s) if (d1 == -1 || d2 == -1) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "URIEncoderDecoder::decode - Bad hex encoding in: ", - s.c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": URIEncoderDecoder::decode - Bad hex encoding in: " + + s); } result += (unsigned char)((d1 << 4) + d2); diff --git a/activemq-cpp/src/main/decaf/internal/net/URIHelper.cpp b/activemq-cpp/src/main/decaf/internal/net/URIHelper.cpp index ff8995e6f..5b516bffa 100644 --- a/activemq-cpp/src/main/decaf/internal/net/URIHelper.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/URIHelper.cpp @@ -21,12 +21,12 @@ #include #include #include -#include #include +#include + using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::net; using namespace decaf::internal; @@ -390,7 +390,7 @@ URIType URIHelper::parseAuthority(bool forceServer, return result; } } - catch (NumberFormatException& e) + catch (std::exception&) { if (forceServer) { @@ -617,7 +617,7 @@ bool URIHelper::isValidIPv4Address(const std::string& host) return false; } } - catch (Exception& e) + catch (std::exception&) { return false; } diff --git a/activemq-cpp/src/main/decaf/internal/net/URLStreamHandlerManager.cpp b/activemq-cpp/src/main/decaf/internal/net/URLStreamHandlerManager.cpp index e5cc9bfd3..0dd9a38c8 100644 --- a/activemq-cpp/src/main/decaf/internal/net/URLStreamHandlerManager.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/URLStreamHandlerManager.cpp @@ -17,10 +17,10 @@ #include +#include #include #include #include -#include #include #include @@ -36,7 +36,6 @@ using namespace decaf::internal::net::https; using namespace decaf::internal::net::file; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// URLStreamHandlerManager* URLStreamHandlerManager::instance; @@ -155,7 +154,7 @@ void URLStreamHandlerManager::setURLStreamHandlerFactory( { if (impl->factory != NULL) { - throw RuntimeException( + throw activemq::exceptions::RuntimeException( __FILE__, __LINE__, "Application already set a URLStreamHandlerFactory"); diff --git a/activemq-cpp/src/main/decaf/internal/net/file/FileHandler.cpp b/activemq-cpp/src/main/decaf/internal/net/file/FileHandler.cpp index 2e94f2e9a..4ec4d3ea2 100644 --- a/activemq-cpp/src/main/decaf/internal/net/file/FileHandler.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/file/FileHandler.cpp @@ -15,13 +15,13 @@ * limitations under the License. */ +#include #include - -#include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::internal::net::file; @@ -45,9 +45,9 @@ decaf::net::URLConnection* FileHandler::openConnection( { if (proxy == NULL) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "proxy object cannot be NULL"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "proxy object cannot be NULL"); } return NULL; diff --git a/activemq-cpp/src/main/decaf/internal/net/http/HttpHandler.cpp b/activemq-cpp/src/main/decaf/internal/net/http/HttpHandler.cpp index 349dec3f3..084554d1f 100644 --- a/activemq-cpp/src/main/decaf/internal/net/http/HttpHandler.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/http/HttpHandler.cpp @@ -15,13 +15,13 @@ * limitations under the License. */ +#include #include - -#include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::internal::net::http; @@ -45,9 +45,9 @@ decaf::net::URLConnection* HttpHandler::openConnection( { if (proxy == NULL) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "proxy object cannot be NULL"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "proxy object cannot be NULL"); } return NULL; diff --git a/activemq-cpp/src/main/decaf/internal/net/https/HttpsHandler.cpp b/activemq-cpp/src/main/decaf/internal/net/https/HttpsHandler.cpp index fff73ea8f..8b82792ba 100644 --- a/activemq-cpp/src/main/decaf/internal/net/https/HttpsHandler.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/https/HttpsHandler.cpp @@ -15,13 +15,13 @@ * limitations under the License. */ +#include #include - -#include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::internal::net::https; @@ -45,9 +45,9 @@ decaf::net::URLConnection* HttpsHandler::openConnection( { if (proxy == NULL) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "proxy object cannot be NULL"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "proxy object cannot be NULL"); } return NULL; diff --git a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp index 729fff987..0254f55e7 100644 --- a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -34,15 +33,17 @@ #include #include +#include #ifdef _WIN32 #include #include +#include +#include #pragma comment(lib, "crypt32.lib") #endif using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::net; using namespace decaf::net::ssl; using namespace decaf::util; @@ -158,9 +159,10 @@ void OpenSSLContextSpi::providerInit(SecureRandom* random) { if (random == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "SecureRandom instance passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "SecureRandom instance passed was NULL."); } try @@ -267,7 +269,6 @@ void OpenSSLContextSpi::providerInit(SecureRandom* random) random->nextBytes(seed); RAND_seed((void*)(&seed[0]), (int)seed.size()); } - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_RETHROW(KeyManagementException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, KeyManagementException) DECAF_CATCHALL_THROW(KeyManagementException) @@ -289,7 +290,6 @@ SocketFactory* OpenSSLContextSpi::providerGetSocketFactory() return this->data->clientSocketFactory.get(); } - DECAF_CATCH_RETHROW(IllegalStateException) DECAF_CATCH_RETHROW(Exception) DECAF_CATCHALL_THROW(Exception) } @@ -310,7 +310,6 @@ ServerSocketFactory* OpenSSLContextSpi::providerGetServerSocketFactory() return this->data->serverSocketFactory.get(); } - DECAF_CATCH_RETHROW(IllegalStateException) DECAF_CATCH_RETHROW(Exception) DECAF_CATCHALL_THROW(Exception) } diff --git a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLParameters.cpp b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLParameters.cpp index 65dcc5372..78e9a7e2b 100644 --- a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLParameters.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLParameters.cpp @@ -15,17 +15,18 @@ * limitations under the License. */ -#include "OpenSSLParameters.h" - -#include +#include +#include -#include +#include "OpenSSLParameters.h" +#include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::internal::net::ssl; @@ -45,7 +46,10 @@ OpenSSLParameters::OpenSSLParameters(SSL_CTX* context) { if (context == NULL) { - throw NullPointerException(__FILE__, __LINE__, "SSL Context was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "SSL Context was NULL"); } // Create a new SSL instance for this Parameters object, each one needs its @@ -60,7 +64,7 @@ OpenSSLParameters::~OpenSSLParameters() { SSL_free(this->ssl); } - DECAF_CATCH_NOTHROW(Exception) + DECAF_CATCH_NOTHROW(decaf::lang::Exception) DECAF_CATCHALL_NOTHROW() } diff --git a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLServerSocket.cpp b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLServerSocket.cpp index 0e816ee1c..707e2f665 100644 --- a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLServerSocket.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLServerSocket.cpp @@ -22,19 +22,18 @@ #include #include +#include #include #include #include #include #include -#include -#include #include #include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::net; using namespace decaf::net::ssl; @@ -87,7 +86,7 @@ OpenSSLServerSocket::OpenSSLServerSocket(OpenSSLParameters* parameters) { if (parameters == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The OpenSSL Parameters object instance passed was NULL."); diff --git a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLServerSocketFactory.cpp b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLServerSocketFactory.cpp index 6ce18397f..e7dce8a29 100644 --- a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLServerSocketFactory.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLServerSocketFactory.cpp @@ -17,20 +17,19 @@ #include "OpenSSLServerSocketFactory.h" -#include -#include - #include #include #include #include +#include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::net; using namespace decaf::net::ssl; @@ -46,9 +45,10 @@ OpenSSLServerSocketFactory::OpenSSLServerSocketFactory(OpenSSLContextSpi* parent { if (parent == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Parent Pointer was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Parent Pointer was NULL."); } } diff --git a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp index 56a7235ec..cc9dccf6b 100644 --- a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp @@ -36,8 +36,6 @@ #include #include #include -#include -#include #include #include #include @@ -49,11 +47,13 @@ #include #include +#include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::net; using namespace decaf::net::ssl; @@ -215,9 +215,7 @@ OpenSSLSocket::OpenSSLSocket(OpenSSLParameters* parameters) { if (parameters == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "The OpenSSL Parameters object instance passed was NULL."); } } @@ -234,9 +232,7 @@ OpenSSLSocket::OpenSSLSocket(OpenSSLParameters* parameters, { if (parameters == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "The OpenSSL Parameters object instance passed was NULL."); } } @@ -255,9 +251,7 @@ OpenSSLSocket::OpenSSLSocket(OpenSSLParameters* parameters, { if (parameters == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "The OpenSSL Parameters object instance passed was NULL."); } } @@ -274,9 +268,7 @@ OpenSSLSocket::OpenSSLSocket(OpenSSLParameters* parameters, { if (parameters == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "The OpenSSL Parameters object instance passed was NULL."); } } @@ -295,9 +287,7 @@ OpenSSLSocket::OpenSSLSocket(OpenSSLParameters* parameters, { if (parameters == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "The OpenSSL Parameters object instance passed was NULL."); } } @@ -389,7 +379,6 @@ void OpenSSLSocket::connect(const std::string& host, int port, int timeout) } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } @@ -697,9 +686,8 @@ void OpenSSLSocket::setUseClientMode(bool value) { if (this->data->handshakeStarted) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Handshake has already been started cannot change mode."); } @@ -759,35 +747,33 @@ int OpenSSLSocket::read(unsigned char* buffer, int size, int offset, int length) if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed is Null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed is Null"); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } if (!this->data->handshakeCompleted) @@ -868,8 +854,6 @@ int OpenSSLSocket::read(unsigned char* buffer, int size, int offset, int length) } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } @@ -888,9 +872,7 @@ void OpenSSLSocket::write(const unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "TcpSocketOutputStream::write - passed buffer is null"); } @@ -904,28 +886,25 @@ void OpenSSLSocket::write(const unsigned char* buffer, if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } if (!this->data->handshakeCompleted) @@ -972,8 +951,6 @@ void OpenSSLSocket::write(const unsigned char* buffer, } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.h b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.h index 6b86ded3a..4e024e361 100644 --- a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.h +++ b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.h @@ -24,6 +24,7 @@ #include #include +#include namespace decaf { @@ -237,8 +238,8 @@ namespace internal * * @throw IOException if an I/O error occurs during the * read. - * @throw NullPointerException if buffer is Null. - * @throw IndexOutOfBoundsException if offset + length is + * @throw std::logic_error if buffer is Null. + * @throw std::out_of_range if offset + length is * greater than buffer size. */ int read(unsigned char* buffer, @@ -262,8 +263,8 @@ namespace internal * * @throw IOException if an I/O error occurs during the * write. - * @throw NullPointerException if buffer is Null. - * @throw IndexOutOfBoundsException if offset + length is + * @throw std::logic_error if buffer is Null. + * @throw std::out_of_range if offset + length is * greater than buffer size. */ void write(const unsigned char* buffer, diff --git a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.cpp b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.cpp index 9701bd044..e1614096e 100644 --- a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketFactory.cpp @@ -17,20 +17,19 @@ #include "OpenSSLSocketFactory.h" -#include -#include - #include #include #include #include +#include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::net; using namespace decaf::net::ssl; @@ -46,9 +45,10 @@ OpenSSLSocketFactory::OpenSSLSocketFactory(OpenSSLContextSpi* parent) { if (parent == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Parent Pointer was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Parent Pointer was NULL."); } } @@ -185,7 +185,8 @@ Socket* OpenSSLSocketFactory::createSocket(Socket* socket DECAF_UNUSED, int port DECAF_UNUSED, bool autoClose DECAF_UNUSED) { - throw UnsupportedOperationException(__FILE__, - __LINE__, - "Wrapped Sockets not yet Supported."); + throw activemq::exceptions::UnsupportedOperationException( + __FILE__, + __LINE__, + "Wrapped Sockets not yet Supported."); } diff --git a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketInputStream.cpp b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketInputStream.cpp index ef17c92ad..4011d334d 100644 --- a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketInputStream.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketInputStream.cpp @@ -17,11 +17,13 @@ #include "OpenSSLSocketInputStream.h" +#include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::internal; using namespace decaf::internal::net; @@ -36,9 +38,10 @@ OpenSSLSocketInputStream::OpenSSLSocketInputStream(OpenSSLSocket* socket) { if (socket == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Socket instance passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Socket instance passed was NULL."); } } @@ -107,9 +110,10 @@ int OpenSSLSocketInputStream::doReadArrayBounded(unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed was NULL."); } try @@ -117,8 +121,6 @@ int OpenSSLSocketInputStream::doReadArrayBounded(unsigned char* buffer, return this->socket->read(buffer, size, offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } @@ -136,7 +138,6 @@ long long OpenSSLSocketInputStream::skip(long long num) return InputStream::skip(num); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketOutputStream.cpp b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketOutputStream.cpp index 814c08743..cb9992221 100644 --- a/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocketOutputStream.cpp @@ -17,11 +17,13 @@ #include "OpenSSLSocketOutputStream.h" +#include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::internal; using namespace decaf::internal::net; @@ -36,9 +38,10 @@ OpenSSLSocketOutputStream::OpenSSLSocketOutputStream(OpenSSLSocket* socket) { if (socket == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "TcpSocket instance passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "TcpSocket instance passed was NULL."); } } @@ -91,9 +94,10 @@ void OpenSSLSocketOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "passed buffer is null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "passed buffer is null"); } if (closed) @@ -106,7 +110,5 @@ void OpenSSLSocketOutputStream::doWriteArrayBounded(const unsigned char* buffer, this->socket->write(buffer, size, offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp b/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp index 5123eda14..ba7e5de24 100644 --- a/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -32,11 +31,13 @@ #include +#include #include #include #include #include #include +#include #include using namespace decaf; @@ -46,7 +47,6 @@ using namespace decaf::internal::net::tcp; using namespace decaf::net; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util::concurrent::atomic; //////////////////////////////////////////////////////////////////////////////// @@ -503,10 +503,9 @@ void TcpSocket::connect(const std::string& hostname, int port, int timeout) if (port < 0 || port > 65535) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Given port is out of range: %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Given port is out of range: " + std::to_string(port)); } if (this->impl->socket == nullptr) @@ -749,12 +748,9 @@ void TcpSocket::connect(const std::string& hostname, int port, int timeout) } throw; } - catch (IllegalArgumentException& ex) + catch (std::invalid_argument& ex) { - AMQ_LOG_ERROR( - "TcpSocket", - "connect() IllegalArgumentException: " << ex.getMessage()); - ex.setMark(__FILE__, __LINE__); + AMQ_LOG_ERROR("TcpSocket", "connect() invalid_argument: " << ex.what()); try { close(); @@ -1349,35 +1345,33 @@ int TcpSocket::read(unsigned char* buffer, int size, int offset, int length) if (buffer == nullptr) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed is Null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed is Null"); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } asio::error_code ec; @@ -1543,8 +1537,6 @@ int TcpSocket::read(unsigned char* buffer, int size, int offset, int length) return static_cast(bytesRead); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } @@ -1563,7 +1555,7 @@ void TcpSocket::write(const unsigned char* buffer, if (buffer == nullptr) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "TcpSocket::write - passed buffer is null"); @@ -1579,28 +1571,25 @@ void TcpSocket::write(const unsigned char* buffer, if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } asio::error_code ec; @@ -1630,8 +1619,6 @@ void TcpSocket::write(const unsigned char* buffer, } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h b/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h index 756f16059..6783c6de1 100644 --- a/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h +++ b/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h @@ -20,12 +20,11 @@ #include #include #include -#include -#include #include #include #include #include +#include namespace decaf { @@ -169,8 +168,8 @@ namespace internal * @return the actual number of bytes read or -1 if at EOF. * * @throw IOException if an I/O error occurs during the read. - * @throw NullPointerException if buffer is Null. - * @throw IndexOutOfBoundsException if offset + length is + * @throw std::logic_error if buffer is Null. + * @throw std::out_of_range if offset + length is * greater than buffer size. */ int read(unsigned char* buffer, @@ -193,8 +192,8 @@ namespace internal * The number of bytes past offset to write. * * @throw IOException if an I/O error occurs during the write. - * @throw NullPointerException if buffer is Null. - * @throw IndexOutOfBoundsException if offset + length is + * @throw std::logic_error if buffer is Null. + * @throw std::out_of_range if offset + length is * greater than buffer size. */ void write(const unsigned char* buffer, diff --git a/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.cpp b/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.cpp index e69bf0af8..1d29f731e 100644 --- a/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.cpp @@ -17,9 +17,12 @@ #include +#include #include #include #include +#include +#include using namespace decaf; using namespace decaf::net; @@ -29,7 +32,6 @@ using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::internal::net::tcp; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace std; //////////////////////////////////////////////////////////////////////////////// @@ -40,9 +42,10 @@ TcpSocketInputStream::TcpSocketInputStream(TcpSocket* socket) { if (socket == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "TcpSocket instance passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "TcpSocket instance passed was NULL."); } } @@ -111,9 +114,10 @@ int TcpSocketInputStream::doReadArrayBounded(unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed was NULL."); } try @@ -121,8 +125,6 @@ int TcpSocketInputStream::doReadArrayBounded(unsigned char* buffer, return this->socket->read(buffer, size, offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } @@ -140,7 +142,6 @@ long long TcpSocketInputStream::skip(long long num) return InputStream::skip(num); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.h b/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.h index 5cfea0daa..677b9d192 100644 --- a/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.h +++ b/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.h @@ -22,8 +22,6 @@ #include #include -#include -#include namespace decaf { diff --git a/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.cpp b/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.cpp index c49683b85..bb91f2836 100644 --- a/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.cpp @@ -21,7 +21,10 @@ #include +#include #include +#include +#include using namespace decaf; using namespace decaf::net; @@ -31,7 +34,6 @@ using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::internal::net::tcp; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace std; //////////////////////////////////////////////////////////////////////////////// @@ -42,9 +44,10 @@ TcpSocketOutputStream::TcpSocketOutputStream(TcpSocket* socket) { if (socket == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "TcpSocket instance passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "TcpSocket instance passed was NULL."); } } @@ -97,9 +100,7 @@ void TcpSocketOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "TcpSocketOutputStream::write - passed buffer is null"); } @@ -114,7 +115,5 @@ void TcpSocketOutputStream::doWriteArrayBounded(const unsigned char* buffer, this->socket->write(buffer, size, offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/internal/nio/BufferFactory.cpp b/activemq-cpp/src/main/decaf/internal/nio/BufferFactory.cpp index e6301b307..1561d3649 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/BufferFactory.cpp +++ b/activemq-cpp/src/main/decaf/internal/nio/BufferFactory.cpp @@ -17,6 +17,7 @@ #include "BufferFactory.h" +#include #include #include #include @@ -24,13 +25,14 @@ #include #include #include +#include +#include using namespace decaf; using namespace decaf::internal; using namespace decaf::internal::nio; using namespace decaf::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// ByteBuffer* BufferFactory::createByteBuffer(int capacity) @@ -39,8 +41,16 @@ ByteBuffer* BufferFactory::createByteBuffer(int capacity) { return new ByteArrayBuffer(capacity); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -53,10 +63,27 @@ ByteBuffer* BufferFactory::createByteBuffer(unsigned char* buffer, { return new ByteArrayBuffer(buffer, size, offset, length, false); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -70,8 +97,16 @@ ByteBuffer* BufferFactory::createByteBuffer(std::vector& buffer) (int)buffer.size(), false); } - DECAF_CATCH_RETHROW(Exception) - DECAF_CATCHALL_THROW(Exception) + catch (Exception& ex) + { + ex.setMark(__FILE__, __LINE__); + throw; + } + catch (...) + { + Exception ex(__FILE__, __LINE__, "caught unknown exception"); + throw ex; + } } //////////////////////////////////////////////////////////////////////////////// @@ -81,8 +116,16 @@ CharBuffer* BufferFactory::createCharBuffer(int capacity) { return new CharArrayBuffer(capacity); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -95,10 +138,27 @@ CharBuffer* BufferFactory::createCharBuffer(char* buffer, { return new CharArrayBuffer(buffer, size, offset, length, false); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -112,8 +172,16 @@ CharBuffer* BufferFactory::createCharBuffer(std::vector& buffer) (int)buffer.size(), false); } - DECAF_CATCH_RETHROW(Exception) - DECAF_CATCHALL_THROW(Exception) + catch (Exception& ex) + { + ex.setMark(__FILE__, __LINE__); + throw; + } + catch (...) + { + Exception ex(__FILE__, __LINE__, "caught unknown exception"); + throw ex; + } } //////////////////////////////////////////////////////////////////////////////// @@ -123,8 +191,16 @@ DoubleBuffer* BufferFactory::createDoubleBuffer(int capacity) { return new DoubleArrayBuffer(capacity); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -137,10 +213,27 @@ DoubleBuffer* BufferFactory::createDoubleBuffer(double* buffer, { return new DoubleArrayBuffer(buffer, size, offset, length, false); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -154,8 +247,16 @@ DoubleBuffer* BufferFactory::createDoubleBuffer(std::vector& buffer) (int)buffer.size(), false); } - DECAF_CATCH_RETHROW(Exception) - DECAF_CATCHALL_THROW(Exception) + catch (Exception& ex) + { + ex.setMark(__FILE__, __LINE__); + throw; + } + catch (...) + { + Exception ex(__FILE__, __LINE__, "caught unknown exception"); + throw ex; + } } //////////////////////////////////////////////////////////////////////////////// @@ -165,8 +266,16 @@ FloatBuffer* BufferFactory::createFloatBuffer(int capacity) { return new FloatArrayBuffer(capacity); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -179,10 +288,27 @@ FloatBuffer* BufferFactory::createFloatBuffer(float* buffer, { return new FloatArrayBuffer(buffer, size, offset, length, false); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -196,8 +322,16 @@ FloatBuffer* BufferFactory::createFloatBuffer(std::vector& buffer) (int)buffer.size(), false); } - DECAF_CATCH_RETHROW(Exception) - DECAF_CATCHALL_THROW(Exception) + catch (Exception& ex) + { + ex.setMark(__FILE__, __LINE__); + throw; + } + catch (...) + { + Exception ex(__FILE__, __LINE__, "caught unknown exception"); + throw ex; + } } //////////////////////////////////////////////////////////////////////////////// @@ -207,8 +341,16 @@ LongBuffer* BufferFactory::createLongBuffer(int capacity) { return new LongArrayBuffer(capacity); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -221,10 +363,27 @@ LongBuffer* BufferFactory::createLongBuffer(long long* buffer, { return new LongArrayBuffer(buffer, size, offset, length, false); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -238,8 +397,16 @@ LongBuffer* BufferFactory::createLongBuffer(std::vector& buffer) (int)buffer.size(), false); } - DECAF_CATCH_RETHROW(Exception) - DECAF_CATCHALL_THROW(Exception) + catch (Exception& ex) + { + ex.setMark(__FILE__, __LINE__); + throw; + } + catch (...) + { + Exception ex(__FILE__, __LINE__, "caught unknown exception"); + throw ex; + } } //////////////////////////////////////////////////////////////////////////////// @@ -249,8 +416,16 @@ IntBuffer* BufferFactory::createIntBuffer(int capacity) { return new IntArrayBuffer(capacity); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -263,10 +438,27 @@ IntBuffer* BufferFactory::createIntBuffer(int* buffer, { return new IntArrayBuffer(buffer, size, offset, length, false); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -280,8 +472,16 @@ IntBuffer* BufferFactory::createIntBuffer(std::vector& buffer) (int)buffer.size(), false); } - DECAF_CATCH_RETHROW(Exception) - DECAF_CATCHALL_THROW(Exception) + catch (Exception& ex) + { + ex.setMark(__FILE__, __LINE__); + throw; + } + catch (...) + { + Exception ex(__FILE__, __LINE__, "caught unknown exception"); + throw ex; + } } //////////////////////////////////////////////////////////////////////////////// @@ -291,8 +491,16 @@ ShortBuffer* BufferFactory::createShortBuffer(int capacity) { return new ShortArrayBuffer(capacity); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -305,10 +513,27 @@ ShortBuffer* BufferFactory::createShortBuffer(short* buffer, { return new ShortArrayBuffer(buffer, size, offset, length, false); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -322,6 +547,14 @@ ShortBuffer* BufferFactory::createShortBuffer(std::vector& buffer) (int)buffer.size(), false); } - DECAF_CATCH_RETHROW(Exception) - DECAF_CATCHALL_THROW(Exception) + catch (Exception& ex) + { + ex.setMark(__FILE__, __LINE__); + throw; + } + catch (...) + { + Exception ex(__FILE__, __LINE__, "caught unknown exception"); + throw ex; + } } diff --git a/activemq-cpp/src/main/decaf/internal/nio/BufferFactory.h b/activemq-cpp/src/main/decaf/internal/nio/BufferFactory.h index 8ce011f8d..5d7ec5b82 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/BufferFactory.h +++ b/activemq-cpp/src/main/decaf/internal/nio/BufferFactory.h @@ -26,8 +26,6 @@ #include #include -#include - namespace decaf { namespace internal @@ -57,7 +55,7 @@ namespace internal * * @return a newly allocated ByteBuffer which the caller owns. * - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::ByteBuffer* createByteBuffer(int capacity); @@ -84,8 +82,8 @@ namespace internal * @return a new ByteBuffer that is backed by buffer, caller owns * the returned pointer. * - * @throws NullPointerException if the buffer given in Null. - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::logic_error if the buffer given in Null. + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::ByteBuffer* createByteBuffer( @@ -123,7 +121,7 @@ namespace internal * * @return a newly allocated CharBuffer which the caller owns. * - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::CharBuffer* createCharBuffer(int capacity); @@ -150,8 +148,8 @@ namespace internal * @return a new CharBuffer that is backed by buffer, caller owns * the returned pointer. * - * @throws NullPointerException if the buffer given in Null. - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::logic_error if the buffer given in Null. + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::CharBuffer* createCharBuffer(char* buffer, @@ -188,7 +186,7 @@ namespace internal * * @return a newly allocated DoubleBuffer which the caller owns. * - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::DoubleBuffer* createDoubleBuffer(int capacity); @@ -215,8 +213,8 @@ namespace internal * @return a new DoubleBuffer that is backed by buffer, caller owns * the returned pointer. * - * @throws NullPointerException if the buffer given in Null. - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::logic_error if the buffer given in Null. + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::DoubleBuffer* createDoubleBuffer(double* buffer, @@ -253,7 +251,7 @@ namespace internal * * @return a newly allocated FloatBuffer which the caller owns. * - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::FloatBuffer* createFloatBuffer(int capacity); @@ -280,8 +278,8 @@ namespace internal * @return a new FloatBuffer that is backed by buffer, caller owns * the returned pointer. * - * @throws NullPointerException if the buffer given in Null. - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::logic_error if the buffer given in Null. + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::FloatBuffer* createFloatBuffer(float* buffer, @@ -315,7 +313,7 @@ namespace internal * @param capacity - the internal buffer's capacity. * @return a newly allocated DoubleBuffer which the caller owns. * - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::LongBuffer* createLongBuffer(int capacity); @@ -342,8 +340,8 @@ namespace internal * @return a new LongBuffer that is backed by buffer, caller owns * the returned pointer. * - * @throws NullPointerException if the buffer given in Null. - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::logic_error if the buffer given in Null. + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::LongBuffer* createLongBuffer(long long* buffer, @@ -380,7 +378,7 @@ namespace internal * * @return a newly allocated IntBuffer which the caller owns. * - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::IntBuffer* createIntBuffer(int capacity); @@ -407,8 +405,8 @@ namespace internal * @return a new IntBuffer that is backed by buffer, caller owns the * returned pointer. * - * @throws NullPointerException if the buffer given in Null. - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::logic_error if the buffer given in Null. + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::IntBuffer* createIntBuffer(int* buffer, @@ -445,7 +443,7 @@ namespace internal * * @return a newly allocated ShortBuffer which the caller owns. * - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::ShortBuffer* createShortBuffer(int capacity); @@ -472,8 +470,8 @@ namespace internal * @return a new ShortBuffer that is backed by buffer, caller owns * the returned pointer. * - * @throws NullPointerException if the buffer given in Null. - * @throws IndexOutOfBoundsException if the capacity specified is + * @throws std::logic_error if the buffer given in Null. + * @throws std::out_of_range if the capacity specified is * negative. */ static decaf::nio::ShortBuffer* createShortBuffer(short* buffer, diff --git a/activemq-cpp/src/main/decaf/internal/nio/ByteArrayBuffer.cpp b/activemq-cpp/src/main/decaf/internal/nio/ByteArrayBuffer.cpp index 4955ec511..6f3319a7f 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/ByteArrayBuffer.cpp +++ b/activemq-cpp/src/main/decaf/internal/nio/ByteArrayBuffer.cpp @@ -21,12 +21,14 @@ #include "decaf/lang/Integer.h" #include "decaf/lang/Long.h" #include "decaf/lang/Short.h" +#include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal::nio; //////////////////////////////////////////////////////////////////////////////// @@ -55,29 +57,42 @@ ByteArrayBuffer::ByteArrayBuffer(unsigned char* array, { if (offset < 0 || offset > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } // Allocate using the ByteArray, not read-only initially. this->_array.reset(new ByteArrayAdapter(array, size, false)); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -95,26 +110,39 @@ ByteArrayBuffer::ByteArrayBuffer(const Pointer& array, { if (offset < 0 || offset > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -139,7 +167,7 @@ unsigned char* ByteArrayBuffer::array() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "ByteArrayBuffer::arrayOffset() - This Buffer has no backing " @@ -156,11 +184,24 @@ unsigned char* ByteArrayBuffer::array() return this->_array->getByteArray(); } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::ReadOnlyBufferException) - DECAF_CATCHALL_THROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -170,7 +211,7 @@ int ByteArrayBuffer::arrayOffset() const { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "ByteArrayBuffer::arrayOffset() - This Buffer has no backing " @@ -187,11 +228,24 @@ int ByteArrayBuffer::arrayOffset() const return this->offset; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::ReadOnlyBufferException) - DECAF_CATCHALL_THROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -234,10 +288,20 @@ ByteArrayBuffer& ByteArrayBuffer::compact() return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::ReadOnlyBufferException) - DECAF_CATCHALL_THROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -256,12 +320,22 @@ unsigned char ByteArrayBuffer::get() const { try { + if (!this->hasRemaining()) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "ByteArrayBuffer::get - Not enough data to fill " + "request.")); + } return this->get(this->_position++); } - DECAF_CATCH_RETHROW(decaf::nio::BufferUnderflowException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::BufferUnderflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferUnderflowException) + DECAF_CATCH_RETHROW(activemq::exceptions::BufferUnderflowException) + DECAF_CATCH_EXCEPTION_CONVERT( + Exception, + activemq::exceptions::BufferUnderflowException) + DECAF_CATCHALL_THROW(activemq::exceptions::BufferUnderflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -271,17 +345,34 @@ unsigned char ByteArrayBuffer::get(int index) const { if ((index) >= this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "ByteArrayBuffer::get - Not enough data to fill request."); + throw activemq::exceptions::IndexOutOfBoundsException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "ByteArrayBuffer::get - Not enough data to fill request.")); } return this->_array->get(offset + index); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -292,10 +383,11 @@ double ByteArrayBuffer::getDouble() unsigned long long lvalue = this->getLong(); return Double::longBitsToDouble(lvalue); } - DECAF_CATCH_RETHROW(decaf::nio::BufferUnderflowException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::BufferUnderflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferUnderflowException) + DECAF_CATCH_RETHROW(activemq::exceptions::BufferUnderflowException) + DECAF_CATCH_EXCEPTION_CONVERT( + Exception, + activemq::exceptions::BufferUnderflowException) + DECAF_CATCHALL_THROW(activemq::exceptions::BufferUnderflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -306,9 +398,25 @@ double ByteArrayBuffer::getDouble(int index) const unsigned long long lvalue = this->getLong(index); return Double::longBitsToDouble(lvalue); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -319,10 +427,11 @@ float ByteArrayBuffer::getFloat() unsigned int ivalue = this->getInt(); return Float::intBitsToFloat(ivalue); } - DECAF_CATCH_RETHROW(decaf::nio::BufferUnderflowException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::BufferUnderflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferUnderflowException) + DECAF_CATCH_RETHROW(activemq::exceptions::BufferUnderflowException) + DECAF_CATCH_EXCEPTION_CONVERT( + Exception, + activemq::exceptions::BufferUnderflowException) + DECAF_CATCHALL_THROW(activemq::exceptions::BufferUnderflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -333,9 +442,25 @@ float ByteArrayBuffer::getFloat(int index) const unsigned int ivalue = this->getInt(index); return Float::intBitsToFloat(ivalue); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -343,14 +468,24 @@ long long ByteArrayBuffer::getLong() { try { + if (this->remaining() < (int)sizeof(long long)) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "ByteArrayBuffer::getLong - Not enough data to fill a long " + "long.")); + } long long value = this->getLong(this->_position); this->_position += (int)sizeof(value); return value; } - DECAF_CATCH_RETHROW(decaf::nio::BufferUnderflowException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::BufferUnderflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferUnderflowException) + DECAF_CATCH_RETHROW(activemq::exceptions::BufferUnderflowException) + DECAF_CATCH_EXCEPTION_CONVERT( + Exception, + activemq::exceptions::BufferUnderflowException) + DECAF_CATCHALL_THROW(activemq::exceptions::BufferUnderflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -360,17 +495,35 @@ long long ByteArrayBuffer::getLong(int index) const { if ((offset + index + (int)sizeof(long long)) > this->limit()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ByteArrayBuffer::getLong(i) - Not " - "enough data to fill a long long."); + throw activemq::exceptions::IndexOutOfBoundsException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "ByteArrayBuffer::getLong(i) - Not " + "enough data to fill a long long.")); } return this->_array->getLongAt(index + offset); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -382,10 +535,11 @@ int ByteArrayBuffer::getInt() this->_position += (int)sizeof(value); return value; } - DECAF_CATCH_RETHROW(decaf::nio::BufferUnderflowException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::BufferUnderflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferUnderflowException); + DECAF_CATCH_RETHROW(activemq::exceptions::BufferUnderflowException) + DECAF_CATCH_EXCEPTION_CONVERT( + Exception, + activemq::exceptions::BufferUnderflowException) + DECAF_CATCHALL_THROW(activemq::exceptions::BufferUnderflowException); } //////////////////////////////////////////////////////////////////////////////// @@ -395,17 +549,35 @@ int ByteArrayBuffer::getInt(int index) const { if ((offset + index + (int)sizeof(int)) > this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "ByteArrayBuffer::getInt(i) - Not enough data to fill an int."); + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "ByteArrayBuffer::getInt(i) - Not enough data to fill an " + "int.")); }; return this->_array->getIntAt(offset + index); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -413,14 +585,24 @@ short ByteArrayBuffer::getShort() { try { + if (this->remaining() < (int)sizeof(short)) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "ByteArrayBuffer::getShort - Not enough data to fill a " + "short.")); + } short value = this->getShort(this->_position); this->_position += (int)sizeof(value); return value; } - DECAF_CATCH_RETHROW(decaf::nio::BufferUnderflowException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::BufferUnderflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferUnderflowException); + DECAF_CATCH_RETHROW(activemq::exceptions::BufferUnderflowException) + DECAF_CATCH_EXCEPTION_CONVERT( + Exception, + activemq::exceptions::BufferUnderflowException) + DECAF_CATCHALL_THROW(activemq::exceptions::BufferUnderflowException); } //////////////////////////////////////////////////////////////////////////////// @@ -430,17 +612,35 @@ short ByteArrayBuffer::getShort(int index) const { if ((offset + index + (int)sizeof(short)) > this->limit()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ByteArrayBuffer::getShort(i) - " - "Not enough data to fill a short."); + throw activemq::exceptions::IndexOutOfBoundsException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "ByteArrayBuffer::getShort(i) - " + "Not enough data to fill a short.")); } return this->_array->getShortAt(offset + index); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -451,11 +651,22 @@ ByteArrayBuffer& ByteArrayBuffer::put(unsigned char value) this->put(this->_position++, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -473,9 +684,8 @@ ByteArrayBuffer& ByteArrayBuffer::put(int index, unsigned char value) if (index >= this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "ByteArrayBuffer::put(i,i) - Not enough data to fill request."); } @@ -483,10 +693,26 @@ ByteArrayBuffer& ByteArrayBuffer::put(int index, unsigned char value) return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -497,11 +723,22 @@ ByteArrayBuffer& ByteArrayBuffer::putChar(char value) this->put(this->_position++, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -512,10 +749,26 @@ ByteArrayBuffer& ByteArrayBuffer::putChar(int index, char value) this->put(index, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -527,11 +780,22 @@ ByteArrayBuffer& ByteArrayBuffer::putDouble(double value) this->_position += (int)sizeof(value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -542,10 +806,26 @@ ByteArrayBuffer& ByteArrayBuffer::putDouble(int index, double value) this->putLong(index, Double::doubleToLongBits(value)); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -557,11 +837,22 @@ ByteArrayBuffer& ByteArrayBuffer::putFloat(float value) this->_position += (int)sizeof(value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -572,10 +863,26 @@ ByteArrayBuffer& ByteArrayBuffer::putFloat(int index, float value) this->putInt(index, Float::floatToIntBits(value)); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -587,11 +894,22 @@ ByteArrayBuffer& ByteArrayBuffer::putLong(long long value) this->_position += (int)sizeof(value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -611,10 +929,26 @@ ByteArrayBuffer& ByteArrayBuffer::putLong(int index, long long value) return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -626,11 +960,22 @@ ByteArrayBuffer& ByteArrayBuffer::putInt(int value) this->_position += (int)sizeof(value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -650,10 +995,26 @@ ByteArrayBuffer& ByteArrayBuffer::putInt(int index, int value) return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -665,11 +1026,22 @@ ByteArrayBuffer& ByteArrayBuffer::putShort(short value) this->_position += (int)sizeof(value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -689,10 +1061,26 @@ ByteArrayBuffer& ByteArrayBuffer::putShort(int index, short value) return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/decaf/internal/nio/ByteArrayBuffer.h b/activemq-cpp/src/main/decaf/internal/nio/ByteArrayBuffer.h index bdb906af9..c7dd92a4f 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/ByteArrayBuffer.h +++ b/activemq-cpp/src/main/decaf/internal/nio/ByteArrayBuffer.h @@ -18,12 +18,9 @@ #ifndef _DECAF_INTERNAL_NIO_BYTEBUFFER_H_ #define _DECAF_INTERNAL_NIO_BYTEBUFFER_H_ +#include #include -#include -#include -#include #include -#include #include #include @@ -159,8 +156,8 @@ namespace internal * @param readOnly * Should this buffer be read-only, default as false. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if the preconditions of size, * offset and length are violated. */ ByteArrayBuffer(unsigned char* array, @@ -184,8 +181,8 @@ namespace internal * @param readOnly * Boolean indicating if this a readOnly buffer. * - * @throws NullPointerException if array is NULL - * @throws IndexOutOfBoundsException if offset is greater than array + * @throws std::logic_error if array is NULL + * @throws std::out_of_range if offset is greater than array * capacity. */ ByteArrayBuffer(const decaf::lang::Pointer& array, diff --git a/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.cpp b/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.cpp index 625246f18..299daca95 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.cpp +++ b/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.cpp @@ -16,16 +16,19 @@ */ #include "CharArrayBuffer.h" +#include #include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::nio; using namespace decaf::internal::util; using namespace decaf::nio; +using activemq::exceptions::BufferUnderflowException; /////////////////////////////////////////////////////////////////////////////// CharArrayBuffer::CharArrayBuffer(int size, bool readOnly) @@ -53,29 +56,42 @@ CharArrayBuffer::CharArrayBuffer(char* array, { if (offset < 0 || offset > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } // Allocate using the ByteArray, not read-only initially. this->_array.reset(new ByteArrayAdapter(array, size, false)); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -93,26 +109,39 @@ CharArrayBuffer::CharArrayBuffer(const Pointer& array, { if (offset < 0 || offset > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -137,10 +166,10 @@ char* CharArrayBuffer::array() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, - "CharArrayBuffer::arrayOffset() - This Buffer has no backing " + "CharArrayBuffer::array() - This Buffer has no backing " "array."); } @@ -154,10 +183,24 @@ char* CharArrayBuffer::array() return this->_array->getCharArray(); } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -167,7 +210,7 @@ int CharArrayBuffer::arrayOffset() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "CharArrayBuffer::arrayOffset() - This Buffer has no backing " @@ -184,10 +227,24 @@ int CharArrayBuffer::arrayOffset() return this->offset; } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -230,10 +287,20 @@ CharBuffer& CharArrayBuffer::compact() return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::ReadOnlyBufferException) - DECAF_CATCHALL_THROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -252,6 +319,15 @@ char CharArrayBuffer::get() { try { + if (!this->hasRemaining()) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "CharArrayBuffer::get - Not enough data to fill " + "request.")); + } return this->get(this->_position++); } DECAF_CATCH_RETHROW(BufferUnderflowException) @@ -266,22 +342,41 @@ char CharArrayBuffer::get(int index) const { if (index < 0) { - throw IndexOutOfBoundsException(__FILE__, __LINE__, "index < 0"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "index < 0"); } if (index >= this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "CharArrayBuffer::get - Not enough data to fill request."); + throw activemq::exceptions::IndexOutOfBoundsException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "CharArrayBuffer::get - Not enough data to fill request.")); } return this->_array->getChar(offset + index); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -292,11 +387,22 @@ CharBuffer& CharArrayBuffer::put(char value) this->put(this->_position++, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -314,14 +420,15 @@ CharBuffer& CharArrayBuffer::put(int index, char value) if (index < 0) { - throw IndexOutOfBoundsException(__FILE__, __LINE__, "index < 0"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "index < 0"); } if (index >= this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CharArrayBuffer::put(i,i) - Not enough data to fill request."); } @@ -329,10 +436,26 @@ CharBuffer& CharArrayBuffer::put(int index, char value) return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -356,31 +479,29 @@ CharSequence* CharArrayBuffer::subSequence(int start, int end) const { if (start < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "start index < 0"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "start index < 0"); } if (end < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "end index < 0"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "end index < 0"); } if (start > end) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CharArrayBuffer::subSequence - start > end"); } if (start > this->limit() || end > this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CharArrayBuffer::subSequence - Sequence exceed limit"); } @@ -390,7 +511,20 @@ CharSequence* CharArrayBuffer::subSequence(int start, int end) const return buffer.release(); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } diff --git a/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.h b/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.h index d7c3c61b9..5f41881d8 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.h +++ b/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.h @@ -18,11 +18,9 @@ #ifndef _DECAF_INTERNAL_NIO_CHARARRAYBUFFER_H_ #define _DECAF_INTERNAL_NIO_CHARARRAYBUFFER_H_ +#include #include -#include -#include #include -#include #include #include @@ -89,8 +87,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if offset is greater than array + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if offset is greater than array * capacity. */ CharArrayBuffer(char* array, @@ -116,8 +114,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if array is NULL - * @throws IndexOutOfBoundsException if offset + length is greater + * @throws std::logic_error if array is NULL + * @throws std::out_of_range if offset + length is greater * than array size. */ CharArrayBuffer(const decaf::lang::Pointer& array, diff --git a/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.cpp b/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.cpp index ac9b87610..bc2e1e29e 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.cpp +++ b/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.cpp @@ -16,14 +16,17 @@ */ #include "DoubleArrayBuffer.h" +#include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::nio; using namespace decaf::internal::util; using namespace decaf::nio; +using activemq::exceptions::BufferUnderflowException; /////////////////////////////////////////////////////////////////////////////// DoubleArrayBuffer::DoubleArrayBuffer(int size, bool readOnly) @@ -55,29 +58,42 @@ DoubleArrayBuffer::DoubleArrayBuffer(double* array, { if (offset < 0 || offset > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } // Allocate using the ByteArray, not read-only initially. this->_array.reset(new ByteArrayAdapter(array, size, false)); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -95,26 +111,39 @@ DoubleArrayBuffer::DoubleArrayBuffer(const Pointer& array, { if (offset < 0 || offset > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -139,10 +168,10 @@ double* DoubleArrayBuffer::array() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, - "DoubleArrayBuffer::arrayOffset() - This Buffer has no backing " + "DoubleArrayBuffer::array() - This Buffer has no backing " "array."); } @@ -156,10 +185,24 @@ double* DoubleArrayBuffer::array() return this->_array->getDoubleArray(); } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -169,7 +212,7 @@ int DoubleArrayBuffer::arrayOffset() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "DoubleArrayBuffer::arrayOffset() - This Buffer has no backing " @@ -186,10 +229,24 @@ int DoubleArrayBuffer::arrayOffset() return this->offset; } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -232,10 +289,20 @@ DoubleBuffer& DoubleArrayBuffer::compact() return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::ReadOnlyBufferException) - DECAF_CATCHALL_THROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -254,6 +321,15 @@ double DoubleArrayBuffer::get() { try { + if (!this->hasRemaining()) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "DoubleArrayBuffer::get - Not enough data to fill " + "request.")); + } return this->get(this->_position++); } DECAF_CATCH_RETHROW(BufferUnderflowException) @@ -268,17 +344,35 @@ double DoubleArrayBuffer::get(int index) const { if (index >= this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "DoubleArrayBuffer::get - Not enough data to fill request."); + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "DoubleArrayBuffer::get - Not enough data to fill " + "request.")); } return this->_array->getDouble(offset + index); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -289,11 +383,22 @@ DoubleBuffer& DoubleArrayBuffer::put(double value) this->put(this->_position++, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -311,20 +416,36 @@ DoubleBuffer& DoubleArrayBuffer::put(int index, double value) if (index >= this->limit()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "DoubleArrayBuffer::put(i,i) - Not " - "enough data to fill request."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "DoubleArrayBuffer::put(i,i) - Not " + "enough data to fill request."); } this->_array->putDouble(index + offset, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.h b/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.h index 062964ecb..ce2a9e39c 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.h +++ b/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.h @@ -18,11 +18,9 @@ #ifndef _DECAF_INTERNAL_NIO_DOUBLEARRAYBUFFER_H_ #define _DECAF_INTERNAL_NIO_DOUBLEARRAYBUFFER_H_ +#include #include -#include -#include #include -#include #include #include @@ -89,8 +87,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if offset is greater than array + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if offset is greater than array * capacity. */ DoubleArrayBuffer(double* array, @@ -116,8 +114,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if array is NULL - * @throws IndexOutOfBoundsException if offset + length is greater + * @throws std::logic_error if array is NULL + * @throws std::out_of_range if offset + length is greater * than array size. */ DoubleArrayBuffer( diff --git a/activemq-cpp/src/main/decaf/internal/nio/FloatArrayBuffer.cpp b/activemq-cpp/src/main/decaf/internal/nio/FloatArrayBuffer.cpp index 476bb44b0..fd212e059 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/FloatArrayBuffer.cpp +++ b/activemq-cpp/src/main/decaf/internal/nio/FloatArrayBuffer.cpp @@ -16,14 +16,17 @@ */ #include "FloatArrayBuffer.h" +#include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::nio; using namespace decaf::internal::util; using namespace decaf::nio; +using activemq::exceptions::BufferUnderflowException; /////////////////////////////////////////////////////////////////////////////// FloatArrayBuffer::FloatArrayBuffer(int size, bool readOnly) @@ -55,29 +58,42 @@ FloatArrayBuffer::FloatArrayBuffer(float* array, { if (offset < 0 || offset > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } // Allocate using the ByteArray, not read-only initially. this->_array.reset(new ByteArrayAdapter(array, size, false)); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -95,26 +111,39 @@ FloatArrayBuffer::FloatArrayBuffer(const Pointer& array, { if (offset < 0 || offset > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -139,10 +168,10 @@ float* FloatArrayBuffer::array() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, - "FloatArrayBuffer::arrayOffset() - This Buffer has no backing " + "FloatArrayBuffer::array() - This Buffer has no backing " "array."); } @@ -156,10 +185,24 @@ float* FloatArrayBuffer::array() return this->_array->getFloatArray(); } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -169,7 +212,7 @@ int FloatArrayBuffer::arrayOffset() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "FloatArrayBuffer::arrayOffset() - This Buffer has no backing " @@ -186,10 +229,24 @@ int FloatArrayBuffer::arrayOffset() return this->offset; } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -232,10 +289,20 @@ FloatBuffer& FloatArrayBuffer::compact() return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::ReadOnlyBufferException) - DECAF_CATCHALL_THROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -254,6 +321,15 @@ float FloatArrayBuffer::get() { try { + if (!this->hasRemaining()) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "FloatArrayBuffer::get - Not enough data to fill " + "request.")); + } return this->get(this->_position++); } DECAF_CATCH_RETHROW(BufferUnderflowException) @@ -268,17 +344,35 @@ float FloatArrayBuffer::get(int index) const { if (index >= this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "FloatArrayBuffer::get - Not enough data to fill request."); + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "FloatArrayBuffer::get - Not enough data to fill " + "request.")); } return this->_array->getFloat(offset + index); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -289,11 +383,22 @@ FloatBuffer& FloatArrayBuffer::put(float value) this->put(this->_position++, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -311,20 +416,36 @@ FloatBuffer& FloatArrayBuffer::put(int index, float value) if (index >= this->limit()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "FloatArrayBuffer::put(i,i) - Not " - "enough data to fill request."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "FloatArrayBuffer::put(i,i) - Not " + "enough data to fill request."); } this->_array->putFloat(index + offset, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/decaf/internal/nio/FloatArrayBuffer.h b/activemq-cpp/src/main/decaf/internal/nio/FloatArrayBuffer.h index 1b88f1cfd..f77bed1e5 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/FloatArrayBuffer.h +++ b/activemq-cpp/src/main/decaf/internal/nio/FloatArrayBuffer.h @@ -18,11 +18,9 @@ #ifndef _DECAF_INTERNAL_NIO_FLOATARRAYBUFFER_H_ #define _DECAF_INTERNAL_NIO_FLOATARRAYBUFFER_H_ +#include #include -#include -#include #include -#include #include #include @@ -89,8 +87,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if offset is greater than array + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if offset is greater than array * capacity. */ FloatArrayBuffer(float* array, @@ -116,8 +114,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if array is NULL - * @throws IndexOutOfBoundsException if offset + length is greater + * @throws std::logic_error if array is NULL + * @throws std::out_of_range if offset + length is greater * than array size. */ FloatArrayBuffer(const decaf::lang::Pointer& array, diff --git a/activemq-cpp/src/main/decaf/internal/nio/IntArrayBuffer.cpp b/activemq-cpp/src/main/decaf/internal/nio/IntArrayBuffer.cpp index df4afef71..e9b8538b1 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/IntArrayBuffer.cpp +++ b/activemq-cpp/src/main/decaf/internal/nio/IntArrayBuffer.cpp @@ -16,14 +16,17 @@ */ #include "IntArrayBuffer.h" +#include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::nio; using namespace decaf::internal::util; using namespace decaf::nio; +using activemq::exceptions::BufferUnderflowException; /////////////////////////////////////////////////////////////////////////////// IntArrayBuffer::IntArrayBuffer(int size, bool readOnly) @@ -54,29 +57,42 @@ IntArrayBuffer::IntArrayBuffer(int* array, { if (offset < 0 || offset > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } // Allocate using the ByteArray, not read-only initially. this->_array.reset(new ByteArrayAdapter(array, size, false)); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -94,26 +110,39 @@ IntArrayBuffer::IntArrayBuffer(const Pointer& array, { if (offset < 0 || offset > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -138,10 +167,10 @@ int* IntArrayBuffer::array() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, - "IntArrayBuffer::arrayOffset() - This Buffer has no backing " + "IntArrayBuffer::array() - This Buffer has no backing " "array."); } @@ -155,10 +184,24 @@ int* IntArrayBuffer::array() return this->_array->getIntArray(); } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -168,7 +211,7 @@ int IntArrayBuffer::arrayOffset() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "IntArrayBuffer::arrayOffset() - This Buffer has no backing " @@ -185,10 +228,24 @@ int IntArrayBuffer::arrayOffset() return this->offset; } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -231,10 +288,20 @@ IntBuffer& IntArrayBuffer::compact() return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::ReadOnlyBufferException) - DECAF_CATCHALL_THROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -253,6 +320,15 @@ int IntArrayBuffer::get() { try { + if (!this->hasRemaining()) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "IntArrayBuffer::get - Not enough data to fill " + "request.")); + } return this->get(this->_position++); } DECAF_CATCH_RETHROW(BufferUnderflowException) @@ -267,17 +343,34 @@ int IntArrayBuffer::get(int index) const { if (index >= this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "IntArrayBuffer::get - Not enough data to fill request."); + throw activemq::exceptions::IndexOutOfBoundsException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "IntArrayBuffer::get - Not enough data to fill request.")); } return this->_array->getInt(offset + index); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -288,11 +381,22 @@ IntBuffer& IntArrayBuffer::put(int value) this->put(this->_position++, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -310,9 +414,8 @@ IntBuffer& IntArrayBuffer::put(int index, int value) if (index >= this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "IntArrayBuffer::put(i,i) - Not enough data to fill request."); } @@ -320,10 +423,26 @@ IntBuffer& IntArrayBuffer::put(int index, int value) return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/decaf/internal/nio/IntArrayBuffer.h b/activemq-cpp/src/main/decaf/internal/nio/IntArrayBuffer.h index e859ac791..dca5092fe 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/IntArrayBuffer.h +++ b/activemq-cpp/src/main/decaf/internal/nio/IntArrayBuffer.h @@ -18,11 +18,9 @@ #ifndef _DECAF_INTERNAL_NIO_INTARRAYBUFFER_H_ #define _DECAF_INTERNAL_NIO_INTARRAYBUFFER_H_ +#include #include -#include -#include #include -#include #include #include @@ -89,8 +87,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if offset is greater than array + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if offset is greater than array * capacity. */ IntArrayBuffer(int* array, @@ -116,8 +114,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if array is NULL - * @throws IndexOutOfBoundsException if offset + length is greater + * @throws std::logic_error if array is NULL + * @throws std::out_of_range if offset + length is greater * than array size. */ IntArrayBuffer(const decaf::lang::Pointer& array, diff --git a/activemq-cpp/src/main/decaf/internal/nio/LongArrayBuffer.cpp b/activemq-cpp/src/main/decaf/internal/nio/LongArrayBuffer.cpp index afd6d15b3..2fa095667 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/LongArrayBuffer.cpp +++ b/activemq-cpp/src/main/decaf/internal/nio/LongArrayBuffer.cpp @@ -16,14 +16,17 @@ */ #include "LongArrayBuffer.h" +#include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::nio; using namespace decaf::internal::util; using namespace decaf::nio; +using activemq::exceptions::BufferUnderflowException; /////////////////////////////////////////////////////////////////////////////// LongArrayBuffer::LongArrayBuffer(int size, bool readOnly) @@ -55,29 +58,42 @@ LongArrayBuffer::LongArrayBuffer(long long* array, { if (offset < 0 || offset > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } // Allocate using the ByteArray, not read-only initially. this->_array.reset(new ByteArrayAdapter(array, size, false)); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -95,26 +111,39 @@ LongArrayBuffer::LongArrayBuffer(const Pointer& array, { if (offset < 0 || offset > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -139,10 +168,10 @@ long long* LongArrayBuffer::array() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, - "LongArrayBuffer::arrayOffset() - This Buffer has no backing " + "LongArrayBuffer::array() - This Buffer has no backing " "array."); } @@ -156,10 +185,24 @@ long long* LongArrayBuffer::array() return this->_array->getLongArray(); } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -169,7 +212,7 @@ int LongArrayBuffer::arrayOffset() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "LongArrayBuffer::arrayOffset() - This Buffer has no backing " @@ -186,10 +229,24 @@ int LongArrayBuffer::arrayOffset() return this->offset; } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -232,10 +289,20 @@ LongBuffer& LongArrayBuffer::compact() return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::ReadOnlyBufferException) - DECAF_CATCHALL_THROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -254,6 +321,15 @@ long long LongArrayBuffer::get() { try { + if (!this->hasRemaining()) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "LongArrayBuffer::get - Not enough data to fill " + "request.")); + } return this->get(this->_position++); } DECAF_CATCH_RETHROW(BufferUnderflowException) @@ -268,17 +344,34 @@ long long LongArrayBuffer::get(int index) const { if (index >= this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "LongArrayBuffer::get - Not enough data to fill request."); + throw activemq::exceptions::IndexOutOfBoundsException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "LongArrayBuffer::get - Not enough data to fill request.")); } return this->_array->getLong(offset + index); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -289,11 +382,22 @@ LongBuffer& LongArrayBuffer::put(long long value) this->put(this->_position++, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -311,9 +415,8 @@ LongBuffer& LongArrayBuffer::put(int index, long long value) if (index >= this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "LongArrayBuffer::put(i,i) - Not enough data to fill request."); } @@ -321,10 +424,26 @@ LongBuffer& LongArrayBuffer::put(int index, long long value) return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/decaf/internal/nio/LongArrayBuffer.h b/activemq-cpp/src/main/decaf/internal/nio/LongArrayBuffer.h index f53f152f5..a234ede7d 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/LongArrayBuffer.h +++ b/activemq-cpp/src/main/decaf/internal/nio/LongArrayBuffer.h @@ -18,11 +18,9 @@ #ifndef _DECAF_INTERNAL_NIO_LONGARRAYBUFFER_H_ #define _DECAF_INTERNAL_NIO_LONGARRAYBUFFER_H_ +#include #include -#include -#include #include -#include #include #include @@ -89,8 +87,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if offset is greater than array + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if offset is greater than array * capacity. */ LongArrayBuffer(long long* array, @@ -116,8 +114,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if array is NULL - * @throws IndexOutOfBoundsException if offset + length is greater + * @throws std::logic_error if array is NULL + * @throws std::out_of_range if offset + length is greater * than array size. */ LongArrayBuffer(const decaf::lang::Pointer& array, diff --git a/activemq-cpp/src/main/decaf/internal/nio/ShortArrayBuffer.cpp b/activemq-cpp/src/main/decaf/internal/nio/ShortArrayBuffer.cpp index 19edea52a..2b0bb906d 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/ShortArrayBuffer.cpp +++ b/activemq-cpp/src/main/decaf/internal/nio/ShortArrayBuffer.cpp @@ -16,14 +16,17 @@ */ #include "ShortArrayBuffer.h" +#include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::nio; using namespace decaf::internal::util; using namespace decaf::nio; +using activemq::exceptions::BufferUnderflowException; /////////////////////////////////////////////////////////////////////////////// ShortArrayBuffer::ShortArrayBuffer(int size, bool readOnly) @@ -55,29 +58,42 @@ ShortArrayBuffer::ShortArrayBuffer(short* array, { if (offset < 0 || offset > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } // Allocate using the ByteArray, not read-only initially. this->_array.reset(new ByteArrayAdapter(array, length, false)); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -95,26 +111,39 @@ ShortArrayBuffer::ShortArrayBuffer(const Pointer& array, { if (offset < 0 || offset > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Offset parameter if out of bounds, %d", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset parameter if out of bounds, " + std::to_string(offset)); } if (length < 0 || offset + length > array->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter if out of bounds, %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter if out of bounds, " + std::to_string(length)); } } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -139,10 +168,10 @@ short* ShortArrayBuffer::array() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, - "ShortArrayBuffer::arrayOffset() - This Buffer has no backing " + "ShortArrayBuffer::array() - This Buffer has no backing " "array."); } @@ -156,10 +185,24 @@ short* ShortArrayBuffer::array() return this->_array->getShortArray(); } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -169,7 +212,7 @@ int ShortArrayBuffer::arrayOffset() { if (!this->hasArray()) { - throw UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "ShortArrayBuffer::arrayOffset() - This Buffer has no backing " @@ -186,10 +229,24 @@ int ShortArrayBuffer::arrayOffset() return this->offset; } - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -232,10 +289,20 @@ ShortBuffer& ShortArrayBuffer::compact() return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, - decaf::nio::ReadOnlyBufferException) - DECAF_CATCHALL_THROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (Exception& ex) + { + throw decaf::nio::ReadOnlyBufferException(ex.getMessage()); + } + catch (...) + { + throw decaf::nio::ReadOnlyBufferException(__FILE__, + __LINE__, + "caught unknown exception"); + } } /////////////////////////////////////////////////////////////////////////////// @@ -254,6 +321,15 @@ short ShortArrayBuffer::get() { try { + if (!this->hasRemaining()) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "ShortArrayBuffer::get - Not enough data to fill " + "request.")); + } return this->get(this->_position++); } DECAF_CATCH_RETHROW(BufferUnderflowException) @@ -268,17 +344,35 @@ short ShortArrayBuffer::get(int index) const { if (index >= this->limit()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "ShortArrayBuffer::get - Not enough data to fill request."); + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "ShortArrayBuffer::get - Not enough data to fill " + "request.")); } return this->_array->getShort(offset + index); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage(__FILE__, + __LINE__, + ex.getMessage())); + } + catch (...) + { + throw activemq::exceptions::BufferUnderflowException( + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + "caught unknown exception")); + } } //////////////////////////////////////////////////////////////////////////////// @@ -289,11 +383,22 @@ ShortBuffer& ShortArrayBuffer::put(short value) this->put(this->_position++, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException& ex) + { + throw decaf::nio::BufferOverflowException(__FILE__, + __LINE__, + "%s", + ex.what()); + } DECAF_CATCH_RETHROW(decaf::nio::BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, decaf::nio::BufferOverflowException) - DECAF_CATCHALL_THROW(decaf::nio::BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP( + decaf::nio::BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -311,20 +416,36 @@ ShortBuffer& ShortArrayBuffer::put(int index, short value) if (index >= this->limit()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ShortArrayBuffer::put(i,i) - Not " - "enough data to fill request."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ShortArrayBuffer::put(i,i) - Not " + "enough data to fill request."); } this->_array->putShort(index + offset, value); return *this; } - DECAF_CATCH_RETHROW(decaf::nio::ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/decaf/internal/nio/ShortArrayBuffer.h b/activemq-cpp/src/main/decaf/internal/nio/ShortArrayBuffer.h index 48fdd48a6..289ddc3c3 100644 --- a/activemq-cpp/src/main/decaf/internal/nio/ShortArrayBuffer.h +++ b/activemq-cpp/src/main/decaf/internal/nio/ShortArrayBuffer.h @@ -18,11 +18,9 @@ #ifndef _DECAF_INTERNAL_NIO_SHORTARRAYBUFFER_H_ #define _DECAF_INTERNAL_NIO_SHORTARRAYBUFFER_H_ +#include #include -#include -#include #include -#include #include #include @@ -89,8 +87,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if offset is greater than array + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if offset is greater than array * capacity. */ ShortArrayBuffer(short* array, @@ -116,8 +114,8 @@ namespace internal * Boolean indicating if this buffer should be read-only, * default as false. * - * @throws NullPointerException if array is NULL - * @throws IndexOutOfBoundsException if offset + length is greater + * @throws std::logic_error if array is NULL + * @throws std::out_of_range if offset + length is greater * than array size. */ ShortArrayBuffer(const decaf::lang::Pointer& array, diff --git a/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.cpp b/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.cpp index b19a9a065..5ae8063c0 100644 --- a/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.cpp +++ b/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.cpp @@ -17,9 +17,11 @@ #include "SecurityRuntime.h" +#include #include #include -#include +#include +#include using namespace decaf; using namespace decaf::security; @@ -27,7 +29,6 @@ using namespace decaf::internal; using namespace decaf::internal::security; using namespace decaf::internal::security::provider; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -93,7 +94,7 @@ SecurityRuntime* SecurityRuntime::getSecurityRuntime() { if (SecurityRuntime::securityRuntime == NULL) { - throw IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "SecurityRuntime Runtime is not Initialized."); diff --git a/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.h b/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.h index cf77cbdeb..f7ee6ce6a 100644 --- a/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.h +++ b/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.h @@ -78,7 +78,7 @@ namespace internal /** * Gets the one and only instance of the Security class, if this is * called before the Security layer has been initialized or after it - * has been shutdown then an IllegalStateException is thrown. + * has been shutdown then std::logic_error is thrown. * * @return pointer to the Security runtime for the Decaf library. */ diff --git a/activemq-cpp/src/main/decaf/internal/security/unix/SecureRandomImpl.cpp b/activemq-cpp/src/main/decaf/internal/security/unix/SecureRandomImpl.cpp index b4b0594c1..ec3e9f70d 100644 --- a/activemq-cpp/src/main/decaf/internal/security/unix/SecureRandomImpl.cpp +++ b/activemq-cpp/src/main/decaf/internal/security/unix/SecureRandomImpl.cpp @@ -18,17 +18,16 @@ #include "SecureRandomImpl.h" #include -#include -#include -#include #include +#include #include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::security; using namespace decaf::internal; @@ -121,18 +120,18 @@ void SecureRandomImpl::providerNextBytes(unsigned char* bytes, int numBytes) { if (bytes == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Byte Buffer passed cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Byte Buffer passed cannot be NULL."); } if (numBytes < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Number of bytes to read was negative: %d", - numBytes); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Number of bytes to read was negative: " + + std::to_string(numBytes)); } if (this->config->randFile && this->config->randFile->is_open()) @@ -143,17 +142,18 @@ void SecureRandomImpl::providerNextBytes(unsigned char* bytes, int numBytes) // never get an EOF or other error, if so its bad. if (!this->config->randFile->good() && !this->config->randFile->eof()) { - throw RuntimeException(__FILE__, - __LINE__, - "Unexpected error while reading random " - "bytes from system resources."); + throw activemq::exceptions::RuntimeException( + __FILE__, + __LINE__, + "Unexpected error while reading random " + "bytes from system resources."); } // Check if we got all the bytes we asked for std::streamsize bytesRead = this->config->randFile->gcount(); if (bytesRead != numBytes) { - throw RuntimeException( + throw activemq::exceptions::RuntimeException( __FILE__, __LINE__, "Could not read requested number of random bytes."); diff --git a/activemq-cpp/src/main/decaf/internal/security/windows/SecureRandomImpl.cpp b/activemq-cpp/src/main/decaf/internal/security/windows/SecureRandomImpl.cpp index 389f4b7f8..dc2a47537 100644 --- a/activemq-cpp/src/main/decaf/internal/security/windows/SecureRandomImpl.cpp +++ b/activemq-cpp/src/main/decaf/internal/security/windows/SecureRandomImpl.cpp @@ -17,17 +17,17 @@ #include "SecureRandomImpl.h" -#include -#include -#include -#include +#include +#include #include +#include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::security; using namespace decaf::internal; using namespace decaf::internal::security; @@ -55,18 +55,18 @@ void SecureRandomImpl::providerNextBytes(unsigned char* bytes, int numBytes) { if (bytes == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Byte Buffer passed cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Byte Buffer passed cannot be NULL."); } if (numBytes < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Number of bytes to read was negative: %d", - numBytes); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Number of bytes to read was negative: " + + std::to_string(numBytes)); } if (numBytes == 0) @@ -81,10 +81,14 @@ void SecureRandomImpl::providerNextBytes(unsigned char* bytes, int numBytes) if (!BCRYPT_SUCCESS(status)) { - throw RuntimeException(__FILE__, - __LINE__, - "BCryptGenRandom failed with NTSTATUS: 0x%08X", - (unsigned int)status); + char message[96]; + std::snprintf(message, + sizeof(message), + "BCryptGenRandom failed with NTSTATUS: 0x%08X", + (unsigned int)status); + throw activemq::exceptions::RuntimeException(__FILE__, + __LINE__, + message); } } diff --git a/activemq-cpp/src/main/decaf/internal/util/ByteArrayAdapter.cpp b/activemq-cpp/src/main/decaf/internal/util/ByteArrayAdapter.cpp index f0c12c5df..2e91613c5 100644 --- a/activemq-cpp/src/main/decaf/internal/util/ByteArrayAdapter.cpp +++ b/activemq-cpp/src/main/decaf/internal/util/ByteArrayAdapter.cpp @@ -17,18 +17,21 @@ #include "ByteArrayAdapter.h" +#include #include #include #include #include #include +#include +#include using namespace decaf; using namespace decaf::nio; using namespace decaf::internal; using namespace decaf::internal::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; //////////////////////////////////////////////////////////////////////////////// ByteArrayAdapter::ByteArrayAdapter(int size) @@ -40,9 +43,8 @@ ByteArrayAdapter::ByteArrayAdapter(int size) { if (size < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Array size given must be greater than zero."); } @@ -64,9 +66,8 @@ ByteArrayAdapter::ByteArrayAdapter(unsigned char* array, int size, bool own) { this->initialize(array, size, own); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(NullPointerException) + DECAF_CATCH_RETHROW(Exception) + DECAF_CATCHALL_THROW(Exception) } //////////////////////////////////////////////////////////////////////////////// @@ -79,9 +80,8 @@ ByteArrayAdapter::ByteArrayAdapter(char* array, int size, bool own) { this->initialize(reinterpret_cast(array), size, own); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(NullPointerException) + DECAF_CATCH_RETHROW(Exception) + DECAF_CATCHALL_THROW(Exception) } //////////////////////////////////////////////////////////////////////////////// @@ -96,9 +96,8 @@ ByteArrayAdapter::ByteArrayAdapter(double* array, int size, bool own) size * (int)sizeof(double), own); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(NullPointerException) + DECAF_CATCH_RETHROW(Exception) + DECAF_CATCHALL_THROW(Exception) } //////////////////////////////////////////////////////////////////////////////// @@ -113,9 +112,8 @@ ByteArrayAdapter::ByteArrayAdapter(float* array, int size, bool own) size * (int)sizeof(float), own); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(NullPointerException) + DECAF_CATCH_RETHROW(Exception) + DECAF_CATCHALL_THROW(Exception) } //////////////////////////////////////////////////////////////////////////////// @@ -130,9 +128,8 @@ ByteArrayAdapter::ByteArrayAdapter(long long* array, int size, bool own) size * (int)sizeof(long long), own); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(NullPointerException) + DECAF_CATCH_RETHROW(Exception) + DECAF_CATCHALL_THROW(Exception) } //////////////////////////////////////////////////////////////////////////////// @@ -147,9 +144,8 @@ ByteArrayAdapter::ByteArrayAdapter(int* array, int size, bool own) size * (int)sizeof(int), own); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(NullPointerException) + DECAF_CATCH_RETHROW(Exception) + DECAF_CATCHALL_THROW(Exception) } //////////////////////////////////////////////////////////////////////////////// @@ -164,9 +160,8 @@ ByteArrayAdapter::ByteArrayAdapter(short* array, int size, bool own) size * (int)sizeof(short), own); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(NullPointerException) + DECAF_CATCH_RETHROW(Exception) + DECAF_CATCHALL_THROW(Exception) } //////////////////////////////////////////////////////////////////////////////// @@ -176,7 +171,7 @@ void ByteArrayAdapter::initialize(unsigned char* array, int size, bool own) { if (array == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ByteArrayAdapter::initialize - Passed Buffer is null"); @@ -184,9 +179,8 @@ void ByteArrayAdapter::initialize(unsigned char* array, int size, bool own) if (size < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Array size given must be greater than zero."); } @@ -226,36 +220,33 @@ void ByteArrayAdapter::read(unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, - "ByteArrayAdapter::write - Passed buffer is null"); + "ByteArrayAdapter::read - Passed buffer is null"); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } if ((offset + length) > this->size) @@ -268,8 +259,6 @@ void ByteArrayAdapter::read(unsigned char* buffer, // Read, starting at offset, length number of bytes to Buffer memcpy(buffer, this->array.bytes + offset, length); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCH_RETHROW(BufferUnderflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferUnderflowException) DECAF_CATCHALL_THROW(BufferUnderflowException) @@ -290,7 +279,7 @@ void ByteArrayAdapter::write(unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ByteArrayAdapter::write - Passed buffer is null"); @@ -298,28 +287,25 @@ void ByteArrayAdapter::write(unsigned char* buffer, if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } if ((offset + length) > this->size) @@ -333,8 +319,6 @@ void ByteArrayAdapter::write(unsigned char* buffer, // Write, starting at offset, length number of bytes from buffer. memcpy(this->array.bytes + offset, buffer, length); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCH_RETHROW(BufferOverflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) @@ -347,18 +331,15 @@ void ByteArrayAdapter::resize(int size) { if (!own) { - throw InvalidStateException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidStateException( "ByteArrayAdapter::resize - Not the array owner, can't resize"); } if (size < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } // Save old state @@ -374,8 +355,27 @@ void ByteArrayAdapter::resize(int size) Math::min((int)oldCapacity, (int)size)); delete[] oldArray; } - DECAF_CATCH_RETHROW(InvalidStateException) - DECAF_CATCHALL_THROW(InvalidStateException) + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::IllegalStateException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -391,16 +391,23 @@ unsigned char& ByteArrayAdapter::operator[](int index) { if (index < 0 || index > this->size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Index %d is out of bounds", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index " + std::to_string(index) + " is out of bounds"); } return this->array.bytes[index]; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -410,16 +417,23 @@ const unsigned char& ByteArrayAdapter::operator[](int index) const { if (index < 0 || index > this->size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Index %d is out of bounds", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index " + std::to_string(index) + " is out of bounds"); } return this->array.bytes[index]; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -429,17 +443,29 @@ unsigned char ByteArrayAdapter::get(int index) const { if (index < 0 || index >= this->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "ByteArrayAdapter::get - Not enough data to fill request."); } return (*this)[index]; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -449,9 +475,22 @@ char ByteArrayAdapter::getChar(int index) const { return (char)this->get(index); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -461,18 +500,30 @@ double ByteArrayAdapter::getDouble(int index) const { if (index < 0 || index >= this->getDoubleCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "ByteArrayAdapter::getDouble(i) - Not enough data to fill a " "long long."); } return this->array.doubles[index]; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -483,9 +534,22 @@ double ByteArrayAdapter::getDoubleAt(int index) const unsigned long long lvalue = this->getLongAt(index); return Double::longBitsToDouble(lvalue); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -495,18 +559,30 @@ float ByteArrayAdapter::getFloat(int index) const { if (index < 0 || index >= this->getFloatCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "ByteArrayAdapter::getFloat(i) - Not enough data to fill a " "long long."); } return this->array.floats[index]; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -517,9 +593,22 @@ float ByteArrayAdapter::getFloatAt(int index) const unsigned int ivalue = this->getIntAt(index); return Float::intBitsToFloat(ivalue); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -529,18 +618,30 @@ long long ByteArrayAdapter::getLong(int index) const { if (index < 0 || index >= this->getLongCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "ByteArrayAdapter::getLong(i) - Not enough data to fill a long " "long."); } return this->array.longs[index]; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -550,9 +651,8 @@ long long ByteArrayAdapter::getLongAt(int index) const { if (index < 0 || (index + (int)sizeof(long long)) > this->getCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "ByteArrayAdapter::getLong(i) - Not enough data to fill a long " "long."); } @@ -577,9 +677,22 @@ long long ByteArrayAdapter::getLongAt(int index) const return value; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -589,17 +702,30 @@ int ByteArrayAdapter::getInt(int index) const { if (index < 0 || index >= this->getIntCapacity()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ByteArrayAdapter::getInt(i) - Not " - "enough data to fill an int."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ByteArrayAdapter::getInt(i) - Not " + "enough data to fill an int."); } return this->array.ints[index]; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -609,10 +735,10 @@ int ByteArrayAdapter::getIntAt(int index) const { if (index < 0 || (index + (int)sizeof(int)) > this->getCapacity()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ByteArrayAdapter::getInt(i) - Not " - "enough data to fill an int."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ByteArrayAdapter::getInt(i) - Not " + "enough data to fill an int."); } unsigned int value = 0; @@ -623,9 +749,22 @@ int ByteArrayAdapter::getIntAt(int index) const return value; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -635,17 +774,30 @@ short ByteArrayAdapter::getShort(int index) const { if (index < 0 || index >= this->getShortCapacity()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ByteArrayAdapter::getShort(i) - " - "Not enough data to fill a short."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ByteArrayAdapter::getShort(i) - " + "Not enough data to fill a short."); } return this->array.shorts[index]; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -655,10 +807,10 @@ short ByteArrayAdapter::getShortAt(int index) const { if (index < 0 || (index + (int)sizeof(short)) > this->getCapacity()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ByteArrayAdapter::getShort(i) - " - "Not enough data to fill a short."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ByteArrayAdapter::getShort(i) - " + "Not enough data to fill a short."); } short value = 0; @@ -668,9 +820,22 @@ short ByteArrayAdapter::getShortAt(int index) const return value; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -680,19 +845,32 @@ ByteArrayAdapter& ByteArrayAdapter::put(int index, unsigned char value) { if (index < 0 || index >= this->getCapacity()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ByteArrayAdapter::put(i,i) - Not " - "enough data to fill request."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ByteArrayAdapter::put(i,i) - Not enough " + "data to fill request."); } (*this)[index] = value; return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -703,9 +881,22 @@ ByteArrayAdapter& ByteArrayAdapter::putChar(int index, char value) this->put(index, value); return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -715,19 +906,31 @@ ByteArrayAdapter& ByteArrayAdapter::putDouble(int index, double value) { if (index < 0 || index >= this->getDoubleCapacity()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "ByteArrayAdapter::putDouble(i,i) - Not enough data to fill " - "request."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ByteArrayAdapter::putDouble(i,i) - Not " + "enough data to fill request."); } this->array.doubles[index] = value; return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -738,9 +941,22 @@ ByteArrayAdapter& ByteArrayAdapter::putDoubleAt(int index, double value) this->putLongAt(index, Double::doubleToLongBits(value)); return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -750,18 +966,31 @@ ByteArrayAdapter& ByteArrayAdapter::putFloat(int index, float value) { if (index < 0 || index >= this->getFloatCapacity()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ByteArrayAdapter::putFloat(i,i) - " - "Not enough data to fill request."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ByteArrayAdapter::putFloat(i,i) - Not " + "enough data to fill request."); } this->array.floats[index] = value; return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -772,9 +1001,22 @@ ByteArrayAdapter& ByteArrayAdapter::putFloatAt(int index, float value) this->putIntAt(index, Float::floatToIntBits(value)); return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -784,18 +1026,31 @@ ByteArrayAdapter& ByteArrayAdapter::putLong(int index, long long value) { if (index < 0 || index >= this->getLongCapacity()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ByteArrayAdapter::putLong(i,i) - " - "Not enough data to fill request."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ByteArrayAdapter::putLong(i,i) - Not " + "enough data to fill request."); } this->array.longs[index] = value; return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -818,9 +1073,22 @@ ByteArrayAdapter& ByteArrayAdapter::putLongAt(int index, long long value) return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -830,18 +1098,31 @@ ByteArrayAdapter& ByteArrayAdapter::putInt(int index, int value) { if (index < 0 || index >= this->getIntCapacity()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ByteArrayAdapter::putInt(i,i) - " - "Not enough data to fill request."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ByteArrayAdapter::putInt(i,i) - Not " + "enough data to fill request."); } this->array.ints[index] = value; return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -860,9 +1141,22 @@ ByteArrayAdapter& ByteArrayAdapter::putIntAt(int index, int value) return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -872,18 +1166,31 @@ ByteArrayAdapter& ByteArrayAdapter::putShort(int index, short value) { if (index < 0 || index >= this->getShortCapacity()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "ByteArrayAdapter::putShort(i,i) - " - "Not enough data to fill request."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ByteArrayAdapter::putShort(i,i) - Not " + "enough data to fill request."); } this->array.shorts[index] = value; return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -900,7 +1207,20 @@ ByteArrayAdapter& ByteArrayAdapter::putShortAt(int index, short value) return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } diff --git a/activemq-cpp/src/main/decaf/internal/util/ByteArrayAdapter.h b/activemq-cpp/src/main/decaf/internal/util/ByteArrayAdapter.h index 8d06d4fb0..2b8179860 100644 --- a/activemq-cpp/src/main/decaf/internal/util/ByteArrayAdapter.h +++ b/activemq-cpp/src/main/decaf/internal/util/ByteArrayAdapter.h @@ -18,12 +18,9 @@ #ifndef _DECAF_INTERNAL_UTIL_BYTEARRAYADAPTER_H_ #define _DECAF_INTERNAL_UTIL_BYTEARRAYADAPTER_H_ -#include -#include -#include -#include +#include #include -#include +#include namespace decaf { @@ -79,7 +76,7 @@ namespace internal * The size of the array, this is the limit we read and write * to. * - * @throws IllegalArgumentException if size is negative. + * @throws std::invalid_argument if size is negative. */ ByteArrayAdapter(int size); @@ -96,8 +93,8 @@ namespace internal * @param own * Indicates if this class is now the owner of the pointer. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if the size is negative. + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if the size is negative. */ ByteArrayAdapter(unsigned char* array, int size, bool own = false); @@ -114,8 +111,8 @@ namespace internal * @param own * Indicates if this class is now the owner of the pointer. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if the size is negative. + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if the size is negative. */ ByteArrayAdapter(char* array, int size, bool own = false); @@ -132,8 +129,8 @@ namespace internal * @param own * Indicates if this class is now the owner of the pointer. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if the size is negative. + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if the size is negative. */ ByteArrayAdapter(double* array, int size, bool own = false); @@ -150,8 +147,8 @@ namespace internal * @param own * Indicates if this class is now the owner of the pointer. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if the size is negative. + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if the size is negative. */ ByteArrayAdapter(float* array, int size, bool own = false); @@ -168,8 +165,8 @@ namespace internal * @param own * Indicates if this class is now the owner of the pointer. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if the size is negative. + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if the size is negative. */ ByteArrayAdapter(long long* array, int size, bool own = false); @@ -186,8 +183,8 @@ namespace internal * @param own * Indicates if this class is now the owner of the pointer. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if the size is negative. + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if the size is negative. */ ByteArrayAdapter(int* array, int size, bool own = false); @@ -204,8 +201,8 @@ namespace internal * @param own * Indicates if this class is now the owner of the pointer. * - * @throws NullPointerException if buffer is NULL - * @throws IndexOutOfBoundsException if the size is negative. + * @throws std::logic_error if buffer is NULL + * @throws std::out_of_range if the size is negative. */ ByteArrayAdapter(short* array, int size, bool own = false); @@ -366,9 +363,9 @@ namespace internal * @param length * The amount of data to read from this array. * - * @throws IndexOutOfBoundsException if the offset + length exceeds + * @throws std::out_of_range if the offset + length exceeds * the size. - * @throws NullPointerException if buffer is null + * @throws std::logic_error if buffer is null * @throws BufferUnderflowException if there is not enough data to * read because the offset or the length is greater than the size of * this array. @@ -393,9 +390,9 @@ namespace internal * @param length * The amount of data to read from this array. * - * @throws IndexOutOfBoundsException if the offset + length exceeds + * @throws std::out_of_range if the offset + length exceeds * the size. - * @throws NullPointerException if buffer is null + * @throws std::logic_error if buffer is null * @throws BufferOverflowException if the amount of data to be * written to this array or the offset given are larger than this * array's size. @@ -412,15 +409,15 @@ namespace internal * will fit into the new array is preserved. * * A ByteArrayAdapter can only be resized when it owns the - * underlying array, if it does not then it will throw an - * InvalidStateException. + * underlying array, if it does not then it will throw + * std::logic_error. * * @param size * The new size of the array. * - * @throws IllegalArgumentException if the size parameter is + * @throws std::invalid_argument if the size parameter is * negative. - * @throws InvalidStateException if this object does not own the + * @throws std::logic_error if this object does not own the * buffer. */ virtual void resize(int size); @@ -439,9 +436,9 @@ namespace internal * @param index * The position in the array to access, if the value is * negative or greater than the size of the underlying array an - * IndexOutOfBoundsException is thrown. + * std::out_of_range is thrown. * - * @throws IndexOutOfBoundsException if the preconditions of index + * @throws std::out_of_range if the preconditions of index * are not met. */ unsigned char& operator[](int index); @@ -455,7 +452,7 @@ namespace internal * * @return the byte that is located at the given index. * - * @throws IndexOutOfBoundsException If index is not smaller than + * @throws std::out_of_range If index is not smaller than * the buffer's limit or is negative. */ virtual unsigned char get(int index) const; @@ -468,7 +465,7 @@ namespace internal * * @return the byte that is located at the given index. * - * @throws IndexOutOfBoundsException If index is not smaller than + * @throws std::out_of_range If index is not smaller than * the buffer's limit or is negative. */ virtual char getChar(int index) const; @@ -484,7 +481,7 @@ namespace internal * * @return the value at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is negative. */ virtual double getDouble(int index) const; @@ -497,7 +494,7 @@ namespace internal * * @return the value at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is negative. */ virtual double getDoubleAt(int index) const; @@ -513,7 +510,7 @@ namespace internal * * @return the value at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is negative. */ virtual float getFloat(int index) const; @@ -526,7 +523,7 @@ namespace internal * * @return the value at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is negative. */ virtual float getFloatAt(int index) const; @@ -542,7 +539,7 @@ namespace internal * * @return the value at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is negative. */ virtual long long getLong(int index) const; @@ -555,7 +552,7 @@ namespace internal * * @return the value at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is negative. */ virtual long long getLongAt(int index) const; @@ -571,7 +568,7 @@ namespace internal * * @return the value at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is negative. */ virtual int getInt(int index) const; @@ -584,7 +581,7 @@ namespace internal * * @return the value at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is negative. */ virtual int getIntAt(int index) const; @@ -600,7 +597,7 @@ namespace internal * * @return the value at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is negative. */ virtual short getShort(int index) const; @@ -613,7 +610,7 @@ namespace internal * * @return the value at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is negative. */ virtual short getShortAt(int index) const; @@ -631,7 +628,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ @@ -651,7 +648,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ @@ -671,7 +668,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ @@ -688,7 +685,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ @@ -708,7 +705,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ @@ -725,7 +722,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ @@ -745,7 +742,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ @@ -762,7 +759,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ @@ -782,7 +779,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ @@ -799,7 +796,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ @@ -819,7 +816,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ @@ -836,7 +833,7 @@ namespace internal * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the + * @throw std::out_of_range if index greater than the * buffer's limit minus the size of the type being written, or index * is negative. */ diff --git a/activemq-cpp/src/main/decaf/internal/util/HexStringParser.cpp b/activemq-cpp/src/main/decaf/internal/util/HexStringParser.cpp index db1bf92c8..cc4d697b9 100644 --- a/activemq-cpp/src/main/decaf/internal/util/HexStringParser.cpp +++ b/activemq-cpp/src/main/decaf/internal/util/HexStringParser.cpp @@ -22,13 +22,13 @@ #include #include #include -#include #include +#include + using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::util; @@ -134,7 +134,7 @@ void HexStringParser::parseExponent(const std::string& exponentStr) exponent = expSign * Long::parseLong(exponentStr); checkedAddExponent(EXPONENT_BASE); } - catch (exceptions::NumberFormatException& e) + catch (std::invalid_argument&) { exponent = expSign * Long::MAX_VALUE; } diff --git a/activemq-cpp/src/main/decaf/internal/util/StringUtils.cpp b/activemq-cpp/src/main/decaf/internal/util/StringUtils.cpp index 518ccf586..82923b3b5 100644 --- a/activemq-cpp/src/main/decaf/internal/util/StringUtils.cpp +++ b/activemq-cpp/src/main/decaf/internal/util/StringUtils.cpp @@ -20,12 +20,14 @@ #include #include -#include -#include +#include +#include + +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::util; @@ -188,9 +190,10 @@ int StringUtils::stringLength(const char* string) { if (string == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Cannot check length of NULL string."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Cannot check length of NULL string."); } int length = 0; @@ -200,7 +203,7 @@ int StringUtils::stringLength(const char* string) if (length == Integer::MAX_VALUE) { - throw RuntimeException( + throw activemq::exceptions::RuntimeException( __FILE__, __LINE__, "String length is longer than Integer::MAX_VALUE"); diff --git a/activemq-cpp/src/main/decaf/internal/util/StringUtils.h b/activemq-cpp/src/main/decaf/internal/util/StringUtils.h index 7e69096af..41ef9a422 100644 --- a/activemq-cpp/src/main/decaf/internal/util/StringUtils.h +++ b/activemq-cpp/src/main/decaf/internal/util/StringUtils.h @@ -52,7 +52,7 @@ namespace internal * @return the length of the string if the size is < * Integer::MAX_VALUE. * - * @throws RuntimeException if the length becomes larger than + * @throws Exception if the length becomes larger than * the max value of an int. */ static int stringLength(const char* string); diff --git a/activemq-cpp/src/main/decaf/internal/util/concurrent/PlatformThread.cpp b/activemq-cpp/src/main/decaf/internal/util/concurrent/PlatformThread.cpp index f59d788f6..241b805d9 100644 --- a/activemq-cpp/src/main/decaf/internal/util/concurrent/PlatformThread.cpp +++ b/activemq-cpp/src/main/decaf/internal/util/concurrent/PlatformThread.cpp @@ -18,22 +18,23 @@ #include #include +#include #include -#include -#include #include +#include #include #include #include #include #include #include +#include +#include #include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::internal; @@ -553,9 +554,10 @@ void PlatformThread::createTlsKey(decaf_tls_key* tlsKey) { if (tlsKey == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "TLS Key pointer must not be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "TLS Key pointer must not be NULL."); } *tlsKey = ++getTlsKeyCounter(); diff --git a/activemq-cpp/src/main/decaf/internal/util/concurrent/ThreadLocalImpl.cpp b/activemq-cpp/src/main/decaf/internal/util/concurrent/ThreadLocalImpl.cpp index f46452e74..dfddadd87 100644 --- a/activemq-cpp/src/main/decaf/internal/util/concurrent/ThreadLocalImpl.cpp +++ b/activemq-cpp/src/main/decaf/internal/util/concurrent/ThreadLocalImpl.cpp @@ -19,11 +19,11 @@ #include -#include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::util; using namespace decaf::internal::util::concurrent; @@ -36,9 +36,10 @@ ThreadLocalImpl::ThreadLocalImpl() if (tlsKey < 0) { - throw RuntimeException(__FILE__, - __LINE__, - "Thread Local storage limit reached."); + throw activemq::exceptions::RuntimeException( + __FILE__, + __LINE__, + "Thread Local storage limit reached."); } } diff --git a/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp b/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp index fab9d83a0..e4f3fa6bc 100644 --- a/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp +++ b/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include @@ -29,18 +28,20 @@ #include #include +#include #include #include #include +#include #include #ifdef __SUNPRO_CC #include +#include #endif using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::atomic; @@ -304,7 +305,7 @@ void runCallback(void* arg) { thread->parent->run(); } - catch (decaf::lang::Throwable& error) + catch (decaf::lang::Exception& error) { if (thread->parent->getUncaughtExceptionHandler() != NULL) { @@ -320,7 +321,7 @@ void runCallback(void* arg) } catch (std::exception& stdEx) { - const RuntimeException error(__FILE__, __LINE__, stdEx.what()); + const Exception error(__FILE__, __LINE__, stdEx.what()); if (thread->parent->getUncaughtExceptionHandler() != NULL) { @@ -336,10 +337,10 @@ void runCallback(void* arg) } catch (...) { - const RuntimeException error(__FILE__, - __LINE__, - "Uncaught exception bubbled up to " - "Thread::run, Thread Terminating."); + const Exception error(__FILE__, + __LINE__, + "Uncaught exception bubbled up to " + "Thread::run, Thread Terminating."); if (thread->parent->getUncaughtExceptionHandler() != NULL) { @@ -462,7 +463,7 @@ ThreadHandle* initThreadHandle(ThreadHandle* thread) { PlatformThread::createMutex(&thread->mutex); } - catch (RuntimeException& ex) + catch (Exception& ex) { throw ex; } @@ -471,7 +472,7 @@ ThreadHandle* initThreadHandle(ThreadHandle* thread) { PlatformThread::createCondition(&thread->condition); } - catch (RuntimeException& ex) + catch (Exception& ex) { PlatformThread::destroyMutex(thread->mutex); throw ex; @@ -577,9 +578,10 @@ void enqueueThread(ThreadHandle** queue, ThreadHandle* thread) if (thread->next != NULL) { - throw RuntimeException(__FILE__, - __LINE__, - "Thread was on a monitor queue already"); + throw activemq::exceptions::RuntimeException( + __FILE__, + __LINE__, + "Thread was on a monitor queue already"); } if (qThread != NULL) @@ -839,7 +841,7 @@ bool doWaitOnMonitor(MonitorHandle* monitor, if (monitor->owner != thread) { - throw IllegalMonitorStateException( + throw activemq::exceptions::IllegalMonitorStateException( __FILE__, __LINE__, "Current Thread is not the lock holder."); @@ -854,7 +856,9 @@ bool doWaitOnMonitor(MonitorHandle* monitor, { thread->interrupted = false; PlatformThread::unlockMutex(thread->mutex); - throw InterruptedException(__FILE__, __LINE__, "Thread interrupted"); + throw activemq::exceptions::InterruptedException(__FILE__, + __LINE__, + "Thread interrupted"); } thread->waiting = true; @@ -950,14 +954,17 @@ bool doWaitOnMonitor(MonitorHandle* monitor, if (interrupted) { - throw InterruptedException(__FILE__, __LINE__, "Thread interrupted"); + throw activemq::exceptions::InterruptedException(__FILE__, + __LINE__, + "Thread interrupted"); } if (!timedOut) { - throw RuntimeException(__FILE__, - __LINE__, - "Invalid state detected at end of Monitor Wait"); + throw activemq::exceptions::RuntimeException( + __FILE__, + __LINE__, + "Invalid state detected at end of Monitor Wait"); } return true; @@ -1090,9 +1097,10 @@ ThreadHandle* Threading::createNewThread(Thread* parent, { if (parent == NULL || name == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "One or more arguments was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "One or more arguments was NULL"); } Pointer thread(new ThreadHandle()); @@ -1148,7 +1156,7 @@ void Threading::destroyThread(ThreadHandle* thread) { Threading::join(thread, 0, 0); } - catch (InterruptedException& ex) + catch (activemq::exceptions::InterruptedException&) { } } @@ -1215,9 +1223,10 @@ void Threading::start(ThreadHandle* thread) { if (thread->state.load(std::memory_order_acquire) > Thread::NEW) { - throw IllegalThreadStateException(__FILE__, - __LINE__, - "Thread already started"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Thread already started"); } PlatformThread::lockMutex(thread->mutex); @@ -1232,10 +1241,8 @@ void Threading::start(ThreadHandle* thread) PlatformThread::unlockMutex(thread->mutex); } - DECAF_CATCH_RETHROW(IllegalThreadStateException) - DECAF_CATCH_RETHROW(RuntimeException) - DECAF_CATCH_EXCEPTION_CONVERT(NullPointerException, RuntimeException) - DECAF_CATCHALL_THROW(RuntimeException) + DECAF_CATCH_RETHROW(Exception) + DECAF_CATCHALL_THROW(Exception) } //////////////////////////////////////////////////////////////////////////////// @@ -1245,9 +1252,7 @@ void Threading::reinitialize(ThreadHandle* thread) { if (thread->state.load(std::memory_order_acquire) != Thread::TERMINATED) { - throw IllegalThreadStateException( - __FILE__, - __LINE__, + throw activemq::exceptions::IllegalStateException( "Thread must be terminated before reinitializing"); } @@ -1288,10 +1293,8 @@ void Threading::reinitialize(ThreadHandle* thread) runCallback, thread); } - DECAF_CATCH_RETHROW(IllegalThreadStateException) - DECAF_CATCH_RETHROW(RuntimeException) - DECAF_CATCH_EXCEPTION_CONVERT(NullPointerException, RuntimeException) - DECAF_CATCHALL_THROW(RuntimeException) + DECAF_CATCH_RETHROW(Exception) + DECAF_CATCHALL_THROW(Exception) } //////////////////////////////////////////////////////////////////////////////// @@ -1444,9 +1447,9 @@ bool Threading::join(ThreadHandle* thread, long long mills, int nanos) { if ((mills < 0) || (nanos < 0) || (nanos >= 1000000)) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Timeout arguments out of range."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Timeout arguments out of range."); } bool timedOut = false; @@ -1634,9 +1637,10 @@ bool Threading::join(ThreadHandle* thread, long long mills, int nanos) if (interrupted) { - throw InterruptedException(__FILE__, - __LINE__, - "Sleeping Thread interrupted"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Sleeping Thread interrupted"); } return timedOut; @@ -1680,9 +1684,9 @@ bool Threading::sleep(long long mills, int nanos) { if ((mills < 0) || (nanos < 0) || (nanos >= 1000000)) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Timeout arguments out of range."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Timeout arguments out of range."); } bool timedOut = false; @@ -1727,9 +1731,10 @@ bool Threading::sleep(long long mills, int nanos) if (interrupted) { - throw InterruptedException(__FILE__, - __LINE__, - "Sleeping Thread interrupted"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Sleeping Thread interrupted"); } return timedOut; @@ -1811,9 +1816,10 @@ void Threading::park(Thread* thread) { if (thread == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Null Thread Pointer Passed."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Null Thread Pointer Passed."); } Threading::park(thread, 0LL, 0LL); @@ -1862,9 +1868,10 @@ bool Threading::park(Thread* thread, long long mills, int nanos) { if (thread == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Null Thread Pointer Passed."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Null Thread Pointer Passed."); } bool timedOut = false; @@ -1930,9 +1937,10 @@ void Threading::unpark(Thread* thread) { if (thread == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Null Thread Pointer Passed."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Null Thread Pointer Passed."); } ThreadHandle* handle = thread->getHandle(); @@ -1998,7 +2006,10 @@ void Threading::returnMonitor(MonitorHandle* monitor, bool alreadyLocked) { if (monitor == NULL) { - throw RuntimeException(__FILE__, __LINE__, "Monitor pointer was null"); + throw activemq::exceptions::RuntimeException( + __FILE__, + __LINE__, + "Monitor pointer was null"); } // The own can return the Monitor in a locked state if its held by the @@ -2009,9 +2020,10 @@ void Threading::returnMonitor(MonitorHandle* monitor, bool alreadyLocked) if ((monitor->owner && monitor->owner != getCurrentThreadHandle()) || monitor->waiting) { - throw IllegalMonitorStateException(__FILE__, - __LINE__, - "Monitor is still in use!"); + throw activemq::exceptions::IllegalMonitorStateException( + __FILE__, + __LINE__, + "Monitor is still in use!"); } if (monitor->owner) @@ -2115,7 +2127,7 @@ void Threading::monitorExitUsingThreadId(MonitorHandle* monitor, { if (monitor->owner != thread) { - throw IllegalMonitorStateException( + throw activemq::exceptions::IllegalMonitorStateException( __FILE__, __LINE__, "Specified thread is not the monitor owner."); @@ -2162,9 +2174,10 @@ int Threading::createThreadLocalSlot(ThreadLocalImpl* threadLocal) { if (threadLocal == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Null ThreadLocalImpl Pointer Passed."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Null ThreadLocalImpl Pointer Passed."); } int index = -1; diff --git a/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.h b/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.h index cccf4d8d3..5dcfe1937 100644 --- a/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.h +++ b/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.h @@ -21,6 +21,7 @@ #include #include +#include #include namespace decaf @@ -95,7 +96,7 @@ namespace internal * @param monitor * The handle of the Monitor to return to the Monitor pool. * - * @throws IllegalMonitorStateException if the monitor is in use + * @throws std::logic_error if the monitor is in use * when returned. */ static void returnMonitor(MonitorHandle* monitor, @@ -139,7 +140,7 @@ namespace internal * @param monitor * Handle to the monitor instance that is to be excited. * - * @throws IllegalMonitorStateException if the caller is not the + * @throws std::logic_error if the caller is not the * owner of the monitor. */ static void exitMonitor(MonitorHandle* monitor); @@ -151,7 +152,7 @@ namespace internal * caller specifies a timeout and that timeout expires before * the monitor is signaled this method returns true. The * calling thread must own the monitor in order to call this - * method, otherwise an IllegalMonitorStateException is thrown. + * method, otherwise an std::logic_error is thrown. * * @param monitor * Handle to the monitor that the calling thread is to wait @@ -166,7 +167,7 @@ namespace internal * @return true if the timeout given expires before the caller * was signaled. * - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * own the monitor. */ static bool waitOnMonitor(MonitorHandle* monitor, @@ -177,14 +178,14 @@ namespace internal * Notify a single waiter on the given Monitor instance, if * there is no thread currently waiting on the specified monitor * then no action is taken. The calling thread must own the - * given monitor otherwise an IllegalMonitorStateException is + * given monitor otherwise an std::logic_error is * thrown. * * @param monitor * The monitor handle that is to have a single waiting * thread signaled. * - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * own the monitor. */ static void notifyWaiter(MonitorHandle* monitor); @@ -194,13 +195,13 @@ namespace internal * are no threads currently waiting on the given monitor * instance then no action is taken. The calling thread must * own the given monitor otherwise an - * IllegalMonitorStateException is thrown. + * std::logic_error is thrown. * * @param monitor * The monitor handle that is to have all of its waiting * thread signaled. * - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * own the monitor. */ static void notifyAllWaiters(MonitorHandle* monitor); @@ -270,8 +271,8 @@ namespace internal * * @return true if the timeout period expired, false otherwise. * - * @throws InterruptedException if the Join was interrupted. - * @throws IllegalArgumentException if the value of mills or + * @throws std::runtime_error if the Join was interrupted. + * @throws std::invalid_argument if the value of mills or * nanos is invalid. */ static bool join(ThreadHandle* thread, diff --git a/activemq-cpp/src/main/decaf/internal/util/concurrent/TransferQueue.h b/activemq-cpp/src/main/decaf/internal/util/concurrent/TransferQueue.h index 40fbb8f3c..9d4aefdc9 100644 --- a/activemq-cpp/src/main/decaf/internal/util/concurrent/TransferQueue.h +++ b/activemq-cpp/src/main/decaf/internal/util/concurrent/TransferQueue.h @@ -20,10 +20,10 @@ #include -#include #include #include #include +#include #include diff --git a/activemq-cpp/src/main/decaf/internal/util/concurrent/TransferStack.h b/activemq-cpp/src/main/decaf/internal/util/concurrent/TransferStack.h index 21931681b..67e7fda2f 100644 --- a/activemq-cpp/src/main/decaf/internal/util/concurrent/TransferStack.h +++ b/activemq-cpp/src/main/decaf/internal/util/concurrent/TransferStack.h @@ -20,8 +20,8 @@ #include -#include #include +#include namespace decaf { diff --git a/activemq-cpp/src/main/decaf/internal/util/concurrent/Transferer.h b/activemq-cpp/src/main/decaf/internal/util/concurrent/Transferer.h index 2f5dab2c0..d211630d0 100644 --- a/activemq-cpp/src/main/decaf/internal/util/concurrent/Transferer.h +++ b/activemq-cpp/src/main/decaf/internal/util/concurrent/Transferer.h @@ -18,8 +18,8 @@ #ifndef _DECAF_INTERNAL_UTIL_CONCURRENT_TRANSFERER_H_ #define _DECAF_INTERNAL_UTIL_CONCURRENT_TRANSFERER_H_ -#include #include +#include namespace decaf { @@ -45,7 +45,7 @@ namespace internal * * @throws TimeoutException if the operation timed out waiting * for the consumer to accept the item offered. - * @throws InterruptedException if the thread was interrupted + * @throws std::runtime_error if the thread was interrupted * while waiting for the consumer to accept the item offered. */ virtual void transfer(E* e, bool timed, long long nanos) = 0; @@ -60,7 +60,7 @@ namespace internal * * @throws TimeoutException if the operation timed out waiting * for the producer to offer an item. - * @throws InterruptedException if the thread was interrupted + * @throws std::runtime_error if the thread was interrupted * while waiting for the producer to offer an item. */ virtual E* transfer(bool timed, long long nanos) = 0; diff --git a/activemq-cpp/src/main/decaf/io/BlockingByteArrayInputStream.cpp b/activemq-cpp/src/main/decaf/io/BlockingByteArrayInputStream.cpp index 0ae9cdb7e..ab4c456fc 100644 --- a/activemq-cpp/src/main/decaf/io/BlockingByteArrayInputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/BlockingByteArrayInputStream.cpp @@ -16,13 +16,14 @@ */ #include "BlockingByteArrayInputStream.h" +#include #include +#include using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// BlockingByteArrayInputStream::BlockingByteArrayInputStream() @@ -135,7 +136,7 @@ int BlockingByteArrayInputStream::doReadArrayBounded(unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "BlockingByteArrayInputStream::read - Passed buffer is Null"); @@ -143,26 +144,23 @@ int BlockingByteArrayInputStream::doReadArrayBounded(unsigned char* buffer, if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + "."); } try @@ -200,8 +198,6 @@ int BlockingByteArrayInputStream::doReadArrayBounded(unsigned char* buffer, return 0; } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/BufferedInputStream.cpp b/activemq-cpp/src/main/decaf/io/BufferedInputStream.cpp index 6cb89a4e7..3c510f780 100644 --- a/activemq-cpp/src/main/decaf/io/BufferedInputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/BufferedInputStream.cpp @@ -19,13 +19,15 @@ #include +#include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// BufferedInputStream::BufferedInputStream(InputStream* stream, bool own) @@ -55,9 +57,9 @@ BufferedInputStream::BufferedInputStream(InputStream* stream, { if (bufferSize < 0) { - throw new IllegalArgumentException(__FILE__, - __LINE__, - "Size must be greater than zero"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Size must be greater than zero"); } this->buff = new unsigned char[bufferSize]; @@ -199,27 +201,26 @@ int BufferedInputStream::doReadArrayBounded(unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed was NULL."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } // For zero, do nothing @@ -314,8 +315,6 @@ int BufferedInputStream::doReadArrayBounded(unsigned char* buffer, } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } @@ -410,7 +409,7 @@ int BufferedInputStream::bufferData(InputStream* inputStream, } unsigned char* temp = new unsigned char[newLength]; - System::arraycopy(temp, 0, buffer, 0, count); + System::arraycopy(buffer, 0, temp, 0, count); std::swap(temp, buffer); delete[] temp; this->bufferSize = newLength; diff --git a/activemq-cpp/src/main/decaf/io/BufferedInputStream.h b/activemq-cpp/src/main/decaf/io/BufferedInputStream.h index 041026de0..e680db016 100644 --- a/activemq-cpp/src/main/decaf/io/BufferedInputStream.h +++ b/activemq-cpp/src/main/decaf/io/BufferedInputStream.h @@ -19,8 +19,8 @@ #define _DECAF_IO_BUFFEREDINPUTSTREAM_H_ #include -#include #include +#include namespace decaf { @@ -72,7 +72,7 @@ namespace io * @param own * Indicates if we own the stream object, defaults to false. * - * @throws IllegalArgumentException is the size is zero or negative. + * @throws std::invalid_argument is the size is zero or negative. */ BufferedInputStream(InputStream* stream, int bufferSize, diff --git a/activemq-cpp/src/main/decaf/io/BufferedOutputStream.cpp b/activemq-cpp/src/main/decaf/io/BufferedOutputStream.cpp index 4e56b06b6..97cdc54ca 100644 --- a/activemq-cpp/src/main/decaf/io/BufferedOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/BufferedOutputStream.cpp @@ -17,14 +17,16 @@ #include "BufferedOutputStream.h" +#include #include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// BufferedOutputStream::BufferedOutputStream(OutputStream* stream, bool own) @@ -52,8 +54,16 @@ BufferedOutputStream::BufferedOutputStream(OutputStream* stream, { this->init(bufSize); } - DECAF_CATCH_RETHROW(IllegalArgumentException) - DECAF_CATCHALL_THROW(IllegalArgumentException) + catch (std::invalid_argument&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -73,9 +83,9 @@ void BufferedOutputStream::init(int bufSize) { if (bufSize < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Size of Buffer cannot be negative."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Size of Buffer cannot be negative."); } this->bufferSize = bufSize; @@ -198,7 +208,7 @@ void BufferedOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "BufferedOutputStream::write - Buffer passed is Null."); @@ -206,28 +216,25 @@ void BufferedOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } // Iterate until all the data is written. @@ -255,7 +262,5 @@ void BufferedOutputStream::doWriteArrayBounded(const unsigned char* buffer, } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/BufferedOutputStream.h b/activemq-cpp/src/main/decaf/io/BufferedOutputStream.h index ada664be1..6542f7f39 100644 --- a/activemq-cpp/src/main/decaf/io/BufferedOutputStream.h +++ b/activemq-cpp/src/main/decaf/io/BufferedOutputStream.h @@ -19,7 +19,7 @@ #define _DECAF_IO_BUFFEREDOUTPUTSTREAM_H_ #include -#include +#include namespace decaf { @@ -78,7 +78,7 @@ namespace io * @param own * Indicates if this class owns the stream pointer. * - * @throws IllegalArgumentException if the bufferSize given is negative. + * @throws std::invalid_argument if the bufferSize given is negative. */ BufferedOutputStream(OutputStream* stream, int bufferSize, diff --git a/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.cpp b/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.cpp index 077fe5942..8d9f15544 100644 --- a/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.cpp @@ -17,13 +17,15 @@ #include "ByteArrayInputStream.h" +#include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// ByteArrayInputStream::ByteArrayInputStream() @@ -122,33 +124,31 @@ void ByteArrayInputStream::setByteArray(const unsigned char* buffer, { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Input Buffer cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Input Buffer cannot be NULL."); } if (bufferSize < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Size given for input buffer was negative."); } if (offset < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Offset given was negative: %d.", - offset); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset given was negative: " + std::to_string(offset) + "."); } if (length < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Length given was negative: %d.", - offset); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Length given was negative: " + std::to_string(length) + "."); } // We're using the default buffer. @@ -212,7 +212,7 @@ int ByteArrayInputStream::doReadArrayBounded(unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ByteArrayInputStream::read - Buffer passed is Null"); @@ -220,28 +220,25 @@ int ByteArrayInputStream::doReadArrayBounded(unsigned char* buffer, if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } if (this->pos >= this->count) @@ -256,8 +253,6 @@ int ByteArrayInputStream::doReadArrayBounded(unsigned char* buffer, return copylen; } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h b/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h index 3e26c0700..0ae6b56b6 100644 --- a/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h +++ b/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h @@ -126,7 +126,7 @@ namespace io * Indicates if this object should take ownership of the array, * default is false. * - * @throws NullPointerException if the buffer is Null. + * @throws std::logic_error if the buffer is Null. * @throws IllegalArguementException if the bufferSize is negative. */ ByteArrayInputStream(const unsigned char* buffer, @@ -149,7 +149,7 @@ namespace io * Indicates if this object should take ownership of the array, * default is false. * - * @throws NullPointerException if the buffer is Null. + * @throws std::logic_error if the buffer is Null. * @throws IllegalArguementException if the bufferSize is negative. */ ByteArrayInputStream(const unsigned char* buffer, @@ -182,7 +182,7 @@ namespace io * @param bufferSize * The size of the buffer. * - * @throws NullPointerException if the buffer is Null. + * @throws std::logic_error if the buffer is Null. * @throws IllegalArguementException if the bufferSize is negative. */ virtual void setByteArray(const unsigned char* buffer, int bufferSize); @@ -200,7 +200,7 @@ namespace io * @param length * The number of bytes to read past the offset. * - * @throws NullPointerException if the buffer is Null. + * @throws std::logic_error if the buffer is Null. * @throws IllegalArguementException if the bufferSize is negative. */ virtual void setByteArray(const unsigned char* buffer, diff --git a/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.cpp b/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.cpp index c1bd3157a..64118735d 100644 --- a/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.cpp @@ -19,13 +19,15 @@ #include +#include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// ByteArrayOutputStream::ByteArrayOutputStream() @@ -45,10 +47,9 @@ ByteArrayOutputStream::ByteArrayOutputStream(int bufferSize) { if (bufferSize <= 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Buffer size given was invalid: %d", - bufferSize); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Buffer size given was invalid: " + std::to_string(bufferSize)); } this->buffer = new unsigned char[bufferSize]; @@ -121,31 +122,31 @@ void ByteArrayOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException(__FILE__, __LINE__, "passed buffer is null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "passed buffer is null"); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + "."); } try @@ -156,8 +157,6 @@ void ByteArrayOutputStream::doWriteArrayBounded(const unsigned char* buffer, this->count += length; } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } @@ -184,15 +183,15 @@ void ByteArrayOutputStream::writeTo(OutputStream* out) const if (out == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Passed stream pointer is null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Passed stream pointer is null"); } out->write(this->buffer, this->count); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h b/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h index fa210e201..4cd7e47ea 100644 --- a/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h +++ b/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h @@ -21,8 +21,8 @@ #include #include -#include +#include #include namespace decaf @@ -66,7 +66,7 @@ namespace io * @param bufferSize * The size to use for the internal buffer. * - * @throw IllegalArgumentException if the size is less than or equal to + * @throws std::invalid_argument if the size is less than or equal to * zero. */ ByteArrayOutputStream(int bufferSize); diff --git a/activemq-cpp/src/main/decaf/io/DataInput.h b/activemq-cpp/src/main/decaf/io/DataInput.h index 02c1c5f5c..e99bfe2e2 100644 --- a/activemq-cpp/src/main/decaf/io/DataInput.h +++ b/activemq-cpp/src/main/decaf/io/DataInput.h @@ -26,8 +26,6 @@ #include #include #include -#include -#include namespace decaf { @@ -275,7 +273,7 @@ namespace io * * @throws IOException if an I/O Error occurs. * @throws EOFException if the end of input is reached. - * @throws IndexOutOfBoundsException if the size value is negative. + * @throws std::out_of_range if the size value is negative. */ virtual void readFully(unsigned char* buffer, int size) = 0; @@ -290,9 +288,9 @@ namespace io * * An I/O error occurs, in which case an IOException other * than EOFException is thrown. * - * If buffer is NULL, a NullPointerException is thrown. If offset+length + * If buffer is NULL, a std::logic_error is thrown. If offset+length * is greater than the length of the array buffer, then an - * IndexOutOfBoundsException is thrown. If length is zero, then no bytes + * std::out_of_range is thrown. If length is zero, then no bytes * are read. Otherwise, the first byte read is stored into element * buffer[off], the next one into buffer[offset+1], and so on. The * number of bytes read is, at most, equal to length. @@ -308,8 +306,8 @@ namespace io * * @throws IOException if an I/O Error occurs. * @throws EOFException if the end of input is reached. - * @throws NullPointerException if the buffer is NULL. - * @throws IndexOutOfBoundsException if the offset + length > size, or + * @throws std::logic_error if the buffer is NULL. + * @throws std::out_of_range if the offset + length > size, or * an int param is negative. */ virtual void readFully(unsigned char* buffer, diff --git a/activemq-cpp/src/main/decaf/io/DataInputStream.cpp b/activemq-cpp/src/main/decaf/io/DataInputStream.cpp index 2d4e744d8..cdceeac17 100644 --- a/activemq-cpp/src/main/decaf/io/DataInputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/DataInputStream.cpp @@ -21,11 +21,14 @@ #include #include +#include #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include +#include +#include #endif using namespace std; @@ -33,7 +36,6 @@ using namespace decaf; using namespace decaf::io; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// DataInputStream::DataInputStream(InputStream* inputStream, bool own) @@ -387,7 +389,6 @@ void DataInputStream::readFully(unsigned char* buffer, int size) this->readFully(buffer, size, 0, size); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCH_RETHROW(EOFException) DECAF_CATCH_RETHROW(IOException) DECAF_CATCHALL_THROW(IOException) @@ -486,40 +487,40 @@ void DataInputStream::readFully(unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException(__FILE__, __LINE__, "Buffer is null"); + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + "Buffer is null"); } if (inputStream == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Base input stream is null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Base input stream is null"); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } int n = 0; @@ -534,8 +535,6 @@ void DataInputStream::readFully(unsigned char* buffer, n += count; } } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCH_RETHROW(EOFException) DECAF_CATCH_RETHROW(IOException) DECAF_CATCHALL_THROW(IOException) diff --git a/activemq-cpp/src/main/decaf/io/DataInputStream.h b/activemq-cpp/src/main/decaf/io/DataInputStream.h index c3df27ebe..4b9280f81 100644 --- a/activemq-cpp/src/main/decaf/io/DataInputStream.h +++ b/activemq-cpp/src/main/decaf/io/DataInputStream.h @@ -22,8 +22,6 @@ #include #include #include -#include -#include namespace decaf { @@ -289,7 +287,7 @@ namespace io * * @throws IOException if an I/O Error occurs. * @throws EOFException if the end of input is reached. - * @throws IndexOutOfBoundsException if the size value is negative. + * @throws std::out_of_range if the size value is negative. */ virtual void readFully(unsigned char* buffer, int size); @@ -304,9 +302,9 @@ namespace io * * An I/O error occurs, in which case an IOException other * than EOFException is thrown. * - * If buffer is NULL, a NullPointerException is thrown. If offset+length + * If buffer is NULL, a std::logic_error is thrown. If offset+length * is greater than the length of the array buffer, then an - * IndexOutOfBoundsException is thrown. If length is zero, then no bytes + * std::out_of_range is thrown. If length is zero, then no bytes * are read. Otherwise, the first byte read is stored into element * buffer[off], the next one into buffer[offset+1], and so on. The * number of bytes read is, at most, equal to length. @@ -322,8 +320,8 @@ namespace io * * @throws IOException if an I/O Error occurs. * @throws EOFException if the end of input is reached. - * @throws NullPointerException if the buffer is NULL. - * @throws IndexOutOfBoundsException if the offset + length > size. + * @throws std::logic_error if the buffer is NULL. + * @throws std::out_of_range if the offset + length > size. */ virtual void readFully(unsigned char* buffer, int size, diff --git a/activemq-cpp/src/main/decaf/io/DataOutput.h b/activemq-cpp/src/main/decaf/io/DataOutput.h index 41896cb71..f048008f3 100644 --- a/activemq-cpp/src/main/decaf/io/DataOutput.h +++ b/activemq-cpp/src/main/decaf/io/DataOutput.h @@ -25,8 +25,6 @@ #include #include -#include -#include namespace decaf { diff --git a/activemq-cpp/src/main/decaf/io/DataOutputStream.cpp b/activemq-cpp/src/main/decaf/io/DataOutputStream.cpp index 1990150a4..825a30215 100644 --- a/activemq-cpp/src/main/decaf/io/DataOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/DataOutputStream.cpp @@ -15,16 +15,17 @@ * limitations under the License. */ +#include #include #include #include #include #include +#include using namespace decaf; using namespace decaf::io; using namespace decaf::util; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// DataOutputStream::DataOutputStream(OutputStream* outputStream, bool own) @@ -77,7 +78,7 @@ void DataOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "DataOutputStream::write - passed buffer is Null"); @@ -85,26 +86,23 @@ void DataOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + "."); } try @@ -113,8 +111,6 @@ void DataOutputStream::doWriteArrayBounded(const unsigned char* buffer, written += length; } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/EOFException.cpp b/activemq-cpp/src/main/decaf/io/EOFException.cpp deleted file mode 100644 index fc317de44..000000000 --- a/activemq-cpp/src/main/decaf/io/EOFException.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "EOFException.h" - -using namespace decaf; -using namespace decaf::io; - -//////////////////////////////////////////////////////////////////////////////// -EOFException::EOFException() - : io::IOException() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -EOFException::~EOFException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -EOFException::EOFException(const Exception& ex) - : io::IOException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -EOFException::EOFException(const EOFException& ex) - : io::IOException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -EOFException::EOFException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : io::IOException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -EOFException::EOFException(const std::exception* cause) - : io::IOException(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -EOFException::EOFException(const char* file, - const int lineNumber, - const char* msg, - ...) - : io::IOException() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/io/EOFException.h b/activemq-cpp/src/main/decaf/io/EOFException.h index 8c1ebaaad..c81d2b4ed 100644 --- a/activemq-cpp/src/main/decaf/io/EOFException.h +++ b/activemq-cpp/src/main/decaf/io/EOFException.h @@ -18,6 +18,8 @@ #ifndef _DECAF_IO_EOFEXCEPTION_H_ #define _DECAF_IO_EOFEXCEPTION_H_ +#include + #include namespace decaf @@ -103,6 +105,61 @@ namespace io virtual ~EOFException() throw(); }; + inline EOFException::EOFException() + : io::IOException() + { + } + + inline EOFException::~EOFException() throw() + { + } + + inline EOFException::EOFException(const lang::Exception& ex) + : io::IOException() + { + *(lang::Exception*)this = ex; + } + + inline EOFException::EOFException(const EOFException& ex) + : io::IOException() + { + *(lang::Exception*)this = ex; + } + + inline EOFException::EOFException(const char* file, + const int lineNumber, + const std::exception* cause, + const char* msg, + ...) + : io::IOException(cause) + { + va_list vargs; + va_start(vargs, msg); + buildMessage(msg, vargs); + va_end(vargs); + + setMark(file, lineNumber); + } + + inline EOFException::EOFException(const std::exception* cause) + : io::IOException(cause) + { + } + + inline EOFException::EOFException(const char* file, + const int lineNumber, + const char* msg, + ...) + : io::IOException() + { + va_list vargs; + va_start(vargs, msg); + buildMessage(msg, vargs); + va_end(vargs); + + setMark(file, lineNumber); + } + } // namespace io } // namespace decaf diff --git a/activemq-cpp/src/main/decaf/io/FilterInputStream.cpp b/activemq-cpp/src/main/decaf/io/FilterInputStream.cpp index 7f61ecb98..35d0b5e68 100644 --- a/activemq-cpp/src/main/decaf/io/FilterInputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/FilterInputStream.cpp @@ -17,13 +17,12 @@ #include "FilterInputStream.h" +#include #include -#include using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// FilterInputStream::FilterInputStream(InputStream* inputStream, bool own) @@ -147,7 +146,6 @@ long long FilterInputStream::skip(long long num) return inputStream->skip(num); } - DECAF_CATCH_RETHROW(UnsupportedOperationException) DECAF_CATCH_RETHROW(IOException) DECAF_CATCHALL_THROW(IOException) } @@ -187,7 +185,6 @@ int FilterInputStream::doReadArray(unsigned char* buffer, int size) return doReadArrayBounded(buffer, size, 0, size); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } @@ -210,8 +207,6 @@ int FilterInputStream::doReadArrayBounded(unsigned char* buffer, return inputStream->read(buffer, size, offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/FilterInputStream.h b/activemq-cpp/src/main/decaf/io/FilterInputStream.h index c0010132b..33e55295d 100644 --- a/activemq-cpp/src/main/decaf/io/FilterInputStream.h +++ b/activemq-cpp/src/main/decaf/io/FilterInputStream.h @@ -20,8 +20,6 @@ #include #include -#include -#include namespace decaf { diff --git a/activemq-cpp/src/main/decaf/io/FilterOutputStream.cpp b/activemq-cpp/src/main/decaf/io/FilterOutputStream.cpp index 5336da6f9..839304e10 100644 --- a/activemq-cpp/src/main/decaf/io/FilterOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/FilterOutputStream.cpp @@ -18,14 +18,14 @@ #include "FilterOutputStream.h" #include -#include +#include +#include #include using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// FilterOutputStream::FilterOutputStream(OutputStream* outputStream, bool own) @@ -89,8 +89,6 @@ void FilterOutputStream::doWriteArray(const unsigned char* buffer, int size) this->doWriteArrayBounded(buffer, size, 0, size); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } @@ -111,7 +109,7 @@ void FilterOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (buffer == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "FilterOutputStream::write - Buffer passed is Null."); @@ -119,28 +117,25 @@ void FilterOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } // Calls the doWriteByte method since subclasses may over override that @@ -151,8 +146,6 @@ void FilterOutputStream::doWriteArrayBounded(const unsigned char* buffer, } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/FilterOutputStream.h b/activemq-cpp/src/main/decaf/io/FilterOutputStream.h index b0f0b6f0b..dc93eb819 100644 --- a/activemq-cpp/src/main/decaf/io/FilterOutputStream.h +++ b/activemq-cpp/src/main/decaf/io/FilterOutputStream.h @@ -20,8 +20,6 @@ #include #include -#include -#include namespace decaf { diff --git a/activemq-cpp/src/main/decaf/io/IOException.cpp b/activemq-cpp/src/main/decaf/io/IOException.cpp deleted file mode 100644 index 88e7968fe..000000000 --- a/activemq-cpp/src/main/decaf/io/IOException.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "IOException.h" - -using namespace decaf; -using namespace decaf::io; -using namespace decaf::lang; - -//////////////////////////////////////////////////////////////////////////////// -IOException::IOException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IOException::~IOException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IOException::IOException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IOException::IOException(const IOException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IOException::IOException(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IOException::IOException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -IOException::IOException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/io/IOException.h b/activemq-cpp/src/main/decaf/io/IOException.h index 8b8db7698..a6586205a 100644 --- a/activemq-cpp/src/main/decaf/io/IOException.h +++ b/activemq-cpp/src/main/decaf/io/IOException.h @@ -17,6 +17,8 @@ #ifndef _DECAF_IO_IOEXCEPTION_H_ #define _DECAF_IO_IOEXCEPTION_H_ +#include + #include namespace decaf @@ -102,6 +104,61 @@ namespace io virtual ~IOException() throw(); }; + inline IOException::IOException() + : lang::Exception() + { + } + + inline IOException::~IOException() throw() + { + } + + inline IOException::IOException(const lang::Exception& ex) + : lang::Exception() + { + *(lang::Exception*)this = ex; + } + + inline IOException::IOException(const IOException& ex) + : lang::Exception() + { + *(lang::Exception*)this = ex; + } + + inline IOException::IOException(const std::exception* cause) + : lang::Exception(cause) + { + } + + inline IOException::IOException(const char* file, + const int lineNumber, + const char* msg, + ...) + : lang::Exception() + { + va_list vargs; + va_start(vargs, msg); + buildMessage(msg, vargs); + va_end(vargs); + + setMark(file, lineNumber); + } + + inline IOException::IOException(const char* file, + const int lineNumber, + const std::exception* cause, + const char* msg, + ...) + : lang::Exception(cause) + { + va_list vargs; + va_start(vargs, msg); + buildMessage(msg, vargs); + va_end(vargs); + + setMark(file, lineNumber); + } + } // namespace io } // namespace decaf diff --git a/activemq-cpp/src/main/decaf/io/InputStream.cpp b/activemq-cpp/src/main/decaf/io/InputStream.cpp index 3162b8268..fc2a67472 100644 --- a/activemq-cpp/src/main/decaf/io/InputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/InputStream.cpp @@ -17,14 +17,13 @@ #include "InputStream.h" +#include +#include #include -#include - using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// InputStream::InputStream() @@ -80,7 +79,6 @@ int InputStream::read(unsigned char* buffer, int size) return this->doReadArray(buffer, size); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } @@ -92,8 +90,6 @@ int InputStream::read(unsigned char* buffer, int size, int offset, int length) return this->doReadArrayBounded(buffer, size, offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } @@ -140,7 +136,6 @@ long long InputStream::skip(long long num) return skipped; } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(UnsupportedOperationException) DECAF_CATCHALL_THROW(IOException) } @@ -152,7 +147,6 @@ int InputStream::doReadArray(unsigned char* buffer, int size) return this->doReadArrayBounded(buffer, size, 0, size); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } @@ -171,16 +165,16 @@ int InputStream::doReadArrayBounded(unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed was NULL"); } if (length > (size - offset)) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Offset + Length given exceeds Buffer size."); } @@ -208,7 +202,5 @@ int InputStream::doReadArrayBounded(unsigned char* buffer, return (int)length; } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/InputStream.h b/activemq-cpp/src/main/decaf/io/InputStream.h index 59cafd116..3f31323ab 100644 --- a/activemq-cpp/src/main/decaf/io/InputStream.h +++ b/activemq-cpp/src/main/decaf/io/InputStream.h @@ -20,12 +20,10 @@ #include #include -#include -#include -#include #include #include #include +#include namespace decaf { @@ -191,7 +189,7 @@ namespace io * @return The number of bytes read or -1 if EOF is detected * * @throws IOException if an I/O error occurs. - * @throws NullPointerException if buffer passed is NULL. + * @throws std::logic_error if buffer passed is NULL. */ virtual int read(unsigned char* buffer, int size); @@ -242,8 +240,8 @@ namespace io * @return The number of bytes read or -1 if EOF is detected * * @throws IOException if an I/O error occurs. - * @throws NullPointerException if buffer passed is NULL. - * @throws IndexOutOfBoundsException if length > size - offset. + * @throws std::logic_error if buffer passed is NULL. + * @throws std::out_of_range if length > size - offset. */ virtual int read(unsigned char* buffer, int size, @@ -269,7 +267,7 @@ namespace io * @return total bytes skipped * * @throws IOException if an I/O error occurs. - * @throws UnsupportedOperationException if the concrete stream class + * @throws std::logic_error if the concrete stream class * does not support skipping bytes. */ virtual long long skip(long long num); diff --git a/activemq-cpp/src/main/decaf/io/InputStreamReader.cpp b/activemq-cpp/src/main/decaf/io/InputStreamReader.cpp index dc12fd651..b966efa3e 100644 --- a/activemq-cpp/src/main/decaf/io/InputStreamReader.cpp +++ b/activemq-cpp/src/main/decaf/io/InputStreamReader.cpp @@ -17,13 +17,14 @@ #include "InputStreamReader.h" +#include #include -#include +#include +#include using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// InputStreamReader::InputStreamReader(InputStream* stream, bool own) @@ -34,9 +35,10 @@ InputStreamReader::InputStreamReader(InputStream* stream, bool own) { if (stream == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The passed InputStream cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The passed InputStream cannot be NULL."); } } @@ -113,8 +115,6 @@ int InputStreamReader::doReadArrayBounded(char* buffer, return this->stream->read((unsigned char*)buffer, size, offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/InputStreamReader.h b/activemq-cpp/src/main/decaf/io/InputStreamReader.h index 321d837b2..ae18176c9 100644 --- a/activemq-cpp/src/main/decaf/io/InputStreamReader.h +++ b/activemq-cpp/src/main/decaf/io/InputStreamReader.h @@ -67,7 +67,7 @@ namespace io * @param own * Does this object own the passed InputStream (defaults to false). * - * @throw NullPointerException if the passed InputStream is NULL. + * @throw std::logic_error if the passed InputStream is NULL. */ InputStreamReader(InputStream* stream, bool own = false); diff --git a/activemq-cpp/src/main/decaf/io/InterruptedIOException.cpp b/activemq-cpp/src/main/decaf/io/InterruptedIOException.cpp deleted file mode 100644 index f99054435..000000000 --- a/activemq-cpp/src/main/decaf/io/InterruptedIOException.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "InterruptedIOException.h" - -using namespace decaf; -using namespace decaf::io; - -//////////////////////////////////////////////////////////////////////////////// -InterruptedIOException::InterruptedIOException() - : io::IOException() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedIOException::~InterruptedIOException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedIOException::InterruptedIOException(const Exception& ex) - : io::IOException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedIOException::InterruptedIOException(const InterruptedIOException& ex) - : io::IOException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedIOException::InterruptedIOException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : io::IOException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedIOException::InterruptedIOException(const std::exception* cause) - : io::IOException(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedIOException::InterruptedIOException(const char* file, - const int lineNumber, - const char* msg, - ...) - : io::IOException() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/io/InterruptedIOException.h b/activemq-cpp/src/main/decaf/io/InterruptedIOException.h index 79efb31fb..e2f8e27af 100644 --- a/activemq-cpp/src/main/decaf/io/InterruptedIOException.h +++ b/activemq-cpp/src/main/decaf/io/InterruptedIOException.h @@ -17,6 +17,8 @@ #ifndef _DECAF_IO_INTERRUPTEDIOEXCEPTION_H_ #define _DECAF_IO_INTERRUPTEDIOEXCEPTION_H_ +#include + #include #include @@ -102,6 +104,65 @@ namespace io virtual ~InterruptedIOException() throw(); }; + inline InterruptedIOException::InterruptedIOException() + : io::IOException() + { + } + + inline InterruptedIOException::~InterruptedIOException() throw() + { + } + + inline InterruptedIOException::InterruptedIOException( + const lang::Exception& ex) + : io::IOException() + { + *(lang::Exception*)this = ex; + } + + inline InterruptedIOException::InterruptedIOException( + const InterruptedIOException& ex) + : io::IOException() + { + *(lang::Exception*)this = ex; + } + + inline InterruptedIOException::InterruptedIOException( + const char* file, + const int lineNumber, + const std::exception* cause, + const char* msg, + ...) + : io::IOException(cause) + { + va_list vargs; + va_start(vargs, msg); + buildMessage(msg, vargs); + va_end(vargs); + + setMark(file, lineNumber); + } + + inline InterruptedIOException::InterruptedIOException( + const std::exception* cause) + : io::IOException(cause) + { + } + + inline InterruptedIOException::InterruptedIOException(const char* file, + const int lineNumber, + const char* msg, + ...) + : io::IOException() + { + va_list vargs; + va_start(vargs, msg); + buildMessage(msg, vargs); + va_end(vargs); + + setMark(file, lineNumber); + } + } // namespace io } // namespace decaf diff --git a/activemq-cpp/src/main/decaf/io/OutputStream.cpp b/activemq-cpp/src/main/decaf/io/OutputStream.cpp index 905081bf0..06a278f81 100644 --- a/activemq-cpp/src/main/decaf/io/OutputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/OutputStream.cpp @@ -19,13 +19,12 @@ #include -#include -#include +#include +#include using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// OutputStream::OutputStream() @@ -73,8 +72,6 @@ void OutputStream::write(const unsigned char* buffer, int size) this->doWriteArray(buffer, size); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } @@ -89,8 +86,6 @@ void OutputStream::write(const unsigned char* buffer, this->doWriteArrayBounded(buffer, size, offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } @@ -113,33 +108,30 @@ void OutputStream::doWriteArrayBounded(const unsigned char* buffer, { if (buffer == NULL) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Buffer pointer passed was NULL."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Buffer pointer passed was NULL."); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + "."); } try @@ -150,7 +142,5 @@ void OutputStream::doWriteArrayBounded(const unsigned char* buffer, } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/OutputStream.h b/activemq-cpp/src/main/decaf/io/OutputStream.h index ad0025818..d13e9bf2c 100644 --- a/activemq-cpp/src/main/decaf/io/OutputStream.h +++ b/activemq-cpp/src/main/decaf/io/OutputStream.h @@ -25,9 +25,6 @@ #include #include -#include -#include - namespace decaf { namespace io @@ -100,8 +97,8 @@ namespace io * The size of the buffer passed. * * @throws IOException if an I/O error occurs. - * @throws NullPointerException thrown if buffer is Null. - * @throws IndexOutOfBoundsException if size value is negative. + * @throws std::logic_error thrown if buffer is Null. + * @throws std::out_of_range if size value is negative. */ virtual void write(const unsigned char* buffer, int size); @@ -126,8 +123,8 @@ namespace io * The number of bytes from the buffer to be written. * * @throws IOException if an I/O error occurs. - * @throws NullPointerException thrown if buffer is Null. - * @throws IndexOutOfBoundsException if the offset + length > size. or + * @throws std::logic_error thrown if buffer is Null. + * @throws std::out_of_range if the offset + length > size. or * one of the parameters is negative. */ virtual void write(const unsigned char* buffer, diff --git a/activemq-cpp/src/main/decaf/io/OutputStreamWriter.cpp b/activemq-cpp/src/main/decaf/io/OutputStreamWriter.cpp index 84e999e14..1a597e90a 100644 --- a/activemq-cpp/src/main/decaf/io/OutputStreamWriter.cpp +++ b/activemq-cpp/src/main/decaf/io/OutputStreamWriter.cpp @@ -17,13 +17,14 @@ #include "OutputStreamWriter.h" +#include #include -#include +#include +#include using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// OutputStreamWriter::OutputStreamWriter(OutputStream* stream, bool own) @@ -33,9 +34,10 @@ OutputStreamWriter::OutputStreamWriter(OutputStream* stream, bool own) { if (stream == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "OutputStream pointer cannot be NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "OutputStream pointer cannot be NULL"); } } @@ -99,15 +101,15 @@ void OutputStreamWriter::doWriteArrayBounded(const char* buffer, if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given buffer was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given buffer was NULL."); } this->stream->write((const unsigned char*)buffer, size, offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/OutputStreamWriter.h b/activemq-cpp/src/main/decaf/io/OutputStreamWriter.h index 0f88b80cf..ba19d0cfa 100644 --- a/activemq-cpp/src/main/decaf/io/OutputStreamWriter.h +++ b/activemq-cpp/src/main/decaf/io/OutputStreamWriter.h @@ -61,7 +61,7 @@ namespace io * Indicates whether this instance own the given OutputStream. * If true then the OutputStream is destroyed when this class is. * - * @throws NullPointerException if the stream is NULL. + * @throws std::logic_error if the stream is NULL. */ OutputStreamWriter(OutputStream* stream, bool own = false); diff --git a/activemq-cpp/src/main/decaf/io/PushbackInputStream.cpp b/activemq-cpp/src/main/decaf/io/PushbackInputStream.cpp index 1a95e39bf..e0bf5a7a2 100644 --- a/activemq-cpp/src/main/decaf/io/PushbackInputStream.cpp +++ b/activemq-cpp/src/main/decaf/io/PushbackInputStream.cpp @@ -17,12 +17,14 @@ #include "PushbackInputStream.h" +#include #include +#include +#include using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// PushbackInputStream::PushbackInputStream(InputStream* stream, bool own) @@ -44,9 +46,8 @@ PushbackInputStream::PushbackInputStream(InputStream* stream, { if (bufSize < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Size of Push Back buffer cannot be negative."); } @@ -151,9 +152,8 @@ void PushbackInputStream::unread(const unsigned char* buffer, int size) { if (size < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Given size of the buffer was negatiev."); } @@ -162,7 +162,6 @@ void PushbackInputStream::unread(const unsigned char* buffer, int size) this->unread(buffer, size, 0, size); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } @@ -181,33 +180,31 @@ void PushbackInputStream::unread(const unsigned char* buffer, if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + "."); } if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer pointer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer pointer passed was NULL."); } try @@ -216,8 +213,6 @@ void PushbackInputStream::unread(const unsigned char* buffer, pos = pos - length; } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } @@ -255,33 +250,31 @@ int PushbackInputStream::doReadArrayBounded(unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer pointer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer pointer passed was NULL."); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + "."); } try @@ -323,7 +316,5 @@ int PushbackInputStream::doReadArrayBounded(unsigned char* buffer, return copiedBytes; } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/PushbackInputStream.h b/activemq-cpp/src/main/decaf/io/PushbackInputStream.h index a13df5872..0b2e3a958 100644 --- a/activemq-cpp/src/main/decaf/io/PushbackInputStream.h +++ b/activemq-cpp/src/main/decaf/io/PushbackInputStream.h @@ -22,6 +22,7 @@ #include #include +#include namespace decaf { @@ -79,7 +80,7 @@ namespace io * Boolean value indicating if this FilterInputStream owns the * wrapped stream. * - * @throws IllegalArgumentException if the bufSize argument is < zero. + * @throws std::invalid_argument if the bufSize argument is < zero. */ PushbackInputStream(InputStream* stream, int bufSize, bool own = false); @@ -109,8 +110,8 @@ namespace io * @param size * The size of the array to be copied. * - * @throws NullPointerException if the buffer passed is NULL. - * @throws IndexOutOfBoundsException if the size value given is + * @throws std::logic_error if the buffer passed is NULL. + * @throws std::out_of_range if the size value given is * negative. * @throws IOException if there is not enough space in the pushback * buffer or this stream has already been closed. @@ -131,8 +132,8 @@ namespace io * @param length * The number of bytes to push back from the passed buffer. * - * @throws NullPointerException if the buffer passed is NULL. - * @throws IndexOutOfBoundsException if the offset + length is greater + * @throws std::logic_error if the buffer passed is NULL. + * @throws std::out_of_range if the offset + length is greater * than the buffer size. * @throws IOException if there is not enough space in the pushback * buffer or this stream has already been closed. diff --git a/activemq-cpp/src/main/decaf/io/Reader.cpp b/activemq-cpp/src/main/decaf/io/Reader.cpp index 37d1384e7..de95cea39 100644 --- a/activemq-cpp/src/main/decaf/io/Reader.cpp +++ b/activemq-cpp/src/main/decaf/io/Reader.cpp @@ -20,13 +20,15 @@ #include #include +#include +#include +#include #include using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::nio; //////////////////////////////////////////////////////////////////////////////// @@ -155,8 +157,6 @@ int Reader::read(decaf::nio::CharBuffer* charBuffer) return this->doReadCharBuffer(charBuffer); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) DECAF_CATCHALL_THROW(IOException) } @@ -218,9 +218,10 @@ int Reader::doReadCharBuffer(decaf::nio::CharBuffer* charBuffer) { if (charBuffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Pointer to CharBuffer cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Pointer to CharBuffer cannot be NULL."); } try @@ -244,7 +245,5 @@ int Reader::doReadCharBuffer(decaf::nio::CharBuffer* charBuffer) return length; } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/Reader.h b/activemq-cpp/src/main/decaf/io/Reader.h index f5c176920..29907919d 100644 --- a/activemq-cpp/src/main/decaf/io/Reader.h +++ b/activemq-cpp/src/main/decaf/io/Reader.h @@ -23,9 +23,6 @@ #include #include -#include -#include - namespace decaf { namespace io @@ -145,7 +142,7 @@ namespace io * reached. * * @throws IOException thrown if an I/O error occurs. - * @throws NullPointerException if buffer is NULL. + * @throws std::logic_error if buffer is NULL. */ virtual int read(char* buffer, int size); @@ -167,8 +164,8 @@ namespace io * reached. * * @throws IOException thrown if an I/O error occurs. - * @throws NullPointerException if buffer is NULL. - * @throws IndexOutOfBoundsException if the offset + length is greater + * @throws std::logic_error if buffer is NULL. + * @throws std::out_of_range if the offset + length is greater * than the array size. */ virtual int read(char* buffer, int size, int offset, int length); diff --git a/activemq-cpp/src/main/decaf/io/UTFDataFormatException.cpp b/activemq-cpp/src/main/decaf/io/UTFDataFormatException.cpp deleted file mode 100644 index 55bd4b0d2..000000000 --- a/activemq-cpp/src/main/decaf/io/UTFDataFormatException.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "UTFDataFormatException.h" - -using namespace decaf; -using namespace decaf::io; - -//////////////////////////////////////////////////////////////////////////////// -UTFDataFormatException::UTFDataFormatException() - : io::IOException() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -UTFDataFormatException::~UTFDataFormatException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -UTFDataFormatException::UTFDataFormatException(const Exception& ex) - : io::IOException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -UTFDataFormatException::UTFDataFormatException(const UTFDataFormatException& ex) - : io::IOException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -UTFDataFormatException::UTFDataFormatException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : io::IOException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -UTFDataFormatException::UTFDataFormatException(const std::exception* cause) - : io::IOException(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -UTFDataFormatException::UTFDataFormatException(const char* file, - const int lineNumber, - const char* msg, - ...) - : io::IOException() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/io/UTFDataFormatException.h b/activemq-cpp/src/main/decaf/io/UTFDataFormatException.h index 7cd59c0d3..28d781b06 100644 --- a/activemq-cpp/src/main/decaf/io/UTFDataFormatException.h +++ b/activemq-cpp/src/main/decaf/io/UTFDataFormatException.h @@ -18,6 +18,8 @@ #ifndef _DECAF_IO_UTFDATAFORMATEXCEPTION_H_ #define _DECAF_IO_UTFDATAFORMATEXCEPTION_H_ +#include + #include namespace decaf @@ -108,6 +110,65 @@ namespace io virtual ~UTFDataFormatException() throw(); }; + inline UTFDataFormatException::UTFDataFormatException() + : io::IOException() + { + } + + inline UTFDataFormatException::~UTFDataFormatException() throw() + { + } + + inline UTFDataFormatException::UTFDataFormatException( + const lang::Exception& ex) + : io::IOException() + { + *(lang::Exception*)this = ex; + } + + inline UTFDataFormatException::UTFDataFormatException( + const UTFDataFormatException& ex) + : io::IOException() + { + *(lang::Exception*)this = ex; + } + + inline UTFDataFormatException::UTFDataFormatException( + const char* file, + const int lineNumber, + const std::exception* cause, + const char* msg, + ...) + : io::IOException(cause) + { + va_list vargs; + va_start(vargs, msg); + buildMessage(msg, vargs); + va_end(vargs); + + setMark(file, lineNumber); + } + + inline UTFDataFormatException::UTFDataFormatException( + const std::exception* cause) + : io::IOException(cause) + { + } + + inline UTFDataFormatException::UTFDataFormatException(const char* file, + const int lineNumber, + const char* msg, + ...) + : io::IOException() + { + va_list vargs; + va_start(vargs, msg); + buildMessage(msg, vargs); + va_end(vargs); + + setMark(file, lineNumber); + } + } // namespace io } // namespace decaf diff --git a/activemq-cpp/src/main/decaf/io/UnsupportedEncodingException.cpp b/activemq-cpp/src/main/decaf/io/UnsupportedEncodingException.cpp deleted file mode 100644 index 075d1e9ce..000000000 --- a/activemq-cpp/src/main/decaf/io/UnsupportedEncodingException.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "UnsupportedEncodingException.h" - -using namespace decaf; -using namespace decaf::io; - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedEncodingException::UnsupportedEncodingException() - : io::IOException() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedEncodingException::~UnsupportedEncodingException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedEncodingException::UnsupportedEncodingException(const Exception& ex) - : io::IOException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedEncodingException::UnsupportedEncodingException( - const UnsupportedEncodingException& ex) - : io::IOException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedEncodingException::UnsupportedEncodingException( - const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : io::IOException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedEncodingException::UnsupportedEncodingException( - const std::exception* cause) - : io::IOException(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedEncodingException::UnsupportedEncodingException(const char* file, - const int lineNumber, - const char* msg, - ...) - : io::IOException() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/io/UnsupportedEncodingException.h b/activemq-cpp/src/main/decaf/io/UnsupportedEncodingException.h index a9edf3d29..34062604d 100644 --- a/activemq-cpp/src/main/decaf/io/UnsupportedEncodingException.h +++ b/activemq-cpp/src/main/decaf/io/UnsupportedEncodingException.h @@ -18,6 +18,8 @@ #ifndef _DECAF_IO_UNSUPPORTEDENCODINGEXCEPTION_H_ #define _DECAF_IO_UNSUPPORTEDENCODINGEXCEPTION_H_ +#include + #include namespace decaf @@ -102,6 +104,66 @@ namespace io virtual ~UnsupportedEncodingException() throw(); }; + inline UnsupportedEncodingException::UnsupportedEncodingException() + : io::IOException() + { + } + + inline UnsupportedEncodingException::~UnsupportedEncodingException() throw() + { + } + + inline UnsupportedEncodingException::UnsupportedEncodingException( + const lang::Exception& ex) + : io::IOException() + { + *(lang::Exception*)this = ex; + } + + inline UnsupportedEncodingException::UnsupportedEncodingException( + const UnsupportedEncodingException& ex) + : io::IOException() + { + *(lang::Exception*)this = ex; + } + + inline UnsupportedEncodingException::UnsupportedEncodingException( + const char* file, + const int lineNumber, + const std::exception* cause, + const char* msg, + ...) + : io::IOException(cause) + { + va_list vargs; + va_start(vargs, msg); + buildMessage(msg, vargs); + va_end(vargs); + + setMark(file, lineNumber); + } + + inline UnsupportedEncodingException::UnsupportedEncodingException( + const std::exception* cause) + : io::IOException(cause) + { + } + + inline UnsupportedEncodingException::UnsupportedEncodingException( + const char* file, + const int lineNumber, + const char* msg, + ...) + : io::IOException() + { + va_list vargs; + va_start(vargs, msg); + buildMessage(msg, vargs); + va_end(vargs); + + setMark(file, lineNumber); + } + } // namespace io } // namespace decaf diff --git a/activemq-cpp/src/main/decaf/io/Writer.cpp b/activemq-cpp/src/main/decaf/io/Writer.cpp index 849645e8b..545fbb80a 100644 --- a/activemq-cpp/src/main/decaf/io/Writer.cpp +++ b/activemq-cpp/src/main/decaf/io/Writer.cpp @@ -19,13 +19,14 @@ #include +#include #include +#include using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// Writer::Writer() @@ -67,7 +68,6 @@ void Writer::write(const char* buffer, int size) this->doWriteArray(buffer, size); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } @@ -79,8 +79,6 @@ void Writer::write(const char* buffer, int size, int offset, int length) this->doWriteArrayBounded(buffer, size, offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } @@ -102,16 +100,14 @@ void Writer::write(const std::string& str, int offset, int length) { if ((offset + length) > (int)str.length()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Given Offset + Length value greater than the String length."); } this->doWriteStringBounded(str.c_str(), offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } @@ -147,7 +143,6 @@ Appendable& Writer::append(const decaf::lang::CharSequence* csq, return this->doAppendCharSequenceStartEnd(csq, start, end); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } @@ -184,7 +179,6 @@ void Writer::doWriteArray(const char* buffer, int size) this->doWriteArrayBounded(buffer, size, 0, size); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } @@ -215,7 +209,6 @@ void Writer::doWriteStringBounded(const std::string& str, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } @@ -273,6 +266,5 @@ decaf::lang::Appendable& Writer::doAppendCharSequenceStartEnd( return *this; } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/io/Writer.h b/activemq-cpp/src/main/decaf/io/Writer.h index 0daf3e843..f891dac1f 100644 --- a/activemq-cpp/src/main/decaf/io/Writer.h +++ b/activemq-cpp/src/main/decaf/io/Writer.h @@ -21,8 +21,6 @@ #include #include #include -#include -#include #include #include @@ -82,7 +80,7 @@ namespace io * The size in bytes of the buffer passed. * * @throws IOException if an I/O error occurs. - * @throws NullPointerException if buffer is NULL. + * @throws std::logic_error if buffer is NULL. */ virtual void write(const char* buffer, int size); @@ -99,8 +97,8 @@ namespace io * The number of bytes in the array to write. * * @throws IOException if an I/O error occurs. - * @throws NullPointerException if buffer is NULL. - * @throws IndexOutOfBoundsException if offset + length > size of the + * @throws std::logic_error if buffer is NULL. + * @throws std::out_of_range if offset + length > size of the * buffer. */ virtual void write(const char* buffer, int size, int offset, int length); @@ -126,7 +124,7 @@ namespace io * The number of bytes in the array to write. * * @throws IOException thrown if an error occurs. - * @throws IndexOutOfBoundsException if offset+length is greater than + * @throws std::out_of_range if offset+length is greater than * the string length. */ virtual void write(const std::string& str, int offset, int length); diff --git a/activemq-cpp/src/main/decaf/lang/AbstractStringBuilder.cpp b/activemq-cpp/src/main/decaf/lang/AbstractStringBuilder.cpp index 3278a3a37..3500a7c8e 100644 --- a/activemq-cpp/src/main/decaf/lang/AbstractStringBuilder.cpp +++ b/activemq-cpp/src/main/decaf/lang/AbstractStringBuilder.cpp @@ -22,16 +22,13 @@ #include #include -#include -#include -#include -#include - +#include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::internal::util; @@ -182,9 +179,10 @@ AbstractStringBuilder::AbstractStringBuilder(int capacity) { if (capacity < 0) { - throw NegativeArraySizeException(__FILE__, - __LINE__, - "Capacity cannot be negative"); + throw activemq::exceptions::IllegalArgumentException( + __FILE__, + __LINE__, + "Capacity cannot be negative"); } impl = new AbstractStringBuilderImpl(capacity); @@ -221,7 +219,10 @@ AbstractStringBuilder::AbstractStringBuilder(const CharSequence* source) { if (source == NULL) { - throw NullPointerException(__FILE__, __LINE__, "CharSequence was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "CharSequence was NULL"); } std::string src = source->toString(); @@ -279,9 +280,7 @@ void AbstractStringBuilder::doAppend(const char* value) { if (value == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "C String cannot be null, call 'doAppendNull' instead"); } @@ -303,9 +302,7 @@ void AbstractStringBuilder::doAppend(const char* value, int offset, int length) { if (value == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "C String cannot be null, call 'doAppendNull' instead"); } @@ -314,9 +311,8 @@ void AbstractStringBuilder::doAppend(const char* value, int offset, int length) if ((offset | length) < 0 || offset > arrayLength || arrayLength - offset < length) { - throw ArrayIndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Invalid offset or length value given."); } @@ -336,9 +332,7 @@ void AbstractStringBuilder::doAppend(const CharSequence* value) { if (value == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "C String cannot be null, call 'doAppendNull' instead"); } @@ -373,9 +367,8 @@ void AbstractStringBuilder::doAppend(const CharSequence* value, if ((start | end) < 0 || start > end || end > arrayLength) { - throw ArrayIndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Invalid start or end value given."); } @@ -440,10 +433,9 @@ void AbstractStringBuilder::doDeleteRange(int start, int end) if (start < 0 || start > impl->length || start > end) { - throw StringIndexOutOfBoundsException(__FILE__, - __LINE__, - "Invalid start index: %d", - start); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid start index: " + std::to_string(start)); } // This method is defined to throw only if start > impl->length and start == @@ -487,10 +479,9 @@ void AbstractStringBuilder::doDeleteCharAt(int index) { if (index < 0 || index >= impl->length) { - throw StringIndexOutOfBoundsException(__FILE__, - __LINE__, - "Invalid index: %d", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid index: " + std::to_string(index)); } doDeleteRange(index, index + 1); @@ -501,10 +492,9 @@ void AbstractStringBuilder::doInsert(int index, char value) { if (index < 0 || index > impl->length) { - throw ArrayIndexOutOfBoundsException(__FILE__, - __LINE__, - "Given index is invalid: %d", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Given index is invalid: " + std::to_string(index)); } impl->move(1, index); @@ -517,17 +507,17 @@ void AbstractStringBuilder::doInsert(int index, const char* value) { if (index < 0 || index > impl->length) { - throw ArrayIndexOutOfBoundsException(__FILE__, - __LINE__, - "Given index is invalid: %d", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Given index is invalid: " + std::to_string(index)); } if (value == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "C String pointer was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "C String pointer was NULL"); } int arrayLength = StringUtils::stringLength(value); @@ -545,10 +535,9 @@ void AbstractStringBuilder::doInsert(int index, const String& value) { if (index < 0 || index > impl->length) { - throw ArrayIndexOutOfBoundsException(__FILE__, - __LINE__, - "Given index is invalid: %d", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Given index is invalid: " + std::to_string(index)); } int stringLength = value.length(); @@ -566,10 +555,9 @@ void AbstractStringBuilder::doInsert(int index, const std::string& value) { if (index < 0 || index > impl->length) { - throw ArrayIndexOutOfBoundsException(__FILE__, - __LINE__, - "Given index is invalid: %d", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Given index is invalid: " + std::to_string(index)); } int stringLength = (int)value.length(); @@ -597,9 +585,10 @@ void AbstractStringBuilder::doInsert(int index, { if (value == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "C string pointer was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "C string pointer was NULL"); } int arrayLength = StringUtils::stringLength(value); @@ -620,20 +609,16 @@ void AbstractStringBuilder::doInsert(int index, return; } - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, - "Invalid string offsets, offset=%d length=%d but C string " - "length=%d", - offset, - length, - arrayLength); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid string offsets, offset=" + std::to_string(offset) + + " length=" + std::to_string(length) + + " but C string length=" + std::to_string(arrayLength)); } - throw StringIndexOutOfBoundsException(__FILE__, - __LINE__, - "Index value given was invalid: %d", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index value given was invalid: " + std::to_string(index)); } //////////////////////////////////////////////////////////////////////////////// @@ -643,19 +628,19 @@ void AbstractStringBuilder::doInsert(int index, const CharSequence* value) { if (value == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "CharSequence pointer was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "CharSequence pointer was NULL"); } doInsert(index, value->toString()); return; } - throw StringIndexOutOfBoundsException(__FILE__, - __LINE__, - "Index value given was invalid: %d", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index value given was invalid: " + std::to_string(index)); } //////////////////////////////////////////////////////////////////////////////// @@ -677,9 +662,8 @@ void AbstractStringBuilder::doInsert(int index, if ((start | end) < 0 || start > end || end > arrayLength) { - throw ArrayIndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Invalid start or end value given."); } @@ -701,10 +685,9 @@ void AbstractStringBuilder::doInsert(int index, return; } - throw StringIndexOutOfBoundsException(__FILE__, - __LINE__, - "Index value given was invalid: %d", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index value given was invalid: " + std::to_string(index)); } //////////////////////////////////////////////////////////////////////////////// @@ -772,10 +755,9 @@ void AbstractStringBuilder::doReplace(int start, int end, const String& value) } } - throw StringIndexOutOfBoundsException(__FILE__, - __LINE__, - "Index value given was invalid: %d", - start); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index value given was invalid: " + std::to_string(start)); } //////////////////////////////////////////////////////////////////////////////// @@ -829,7 +811,9 @@ char AbstractStringBuilder::charAt(int index) const { if (index < 0 || index >= impl->length) { - throw StringIndexOutOfBoundsException(__FILE__, __LINE__, index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid index: " + std::to_string(index)); } return impl->value[index]; @@ -853,44 +837,41 @@ void AbstractStringBuilder::getChars(int start, { if (start > impl->length || end > impl->length || start > end) { - throw StringIndexOutOfBoundsException(__FILE__, - __LINE__, - "Invalid range: %d : %d", - start, - end); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid range: " + std::to_string(start) + " : " + + std::to_string(end)); } if (destSize < 0) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Destination size cannot be negative"); } if (destStart < 0) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Destination start index cannot be negative"); } if ((destStart + (end - start)) > destSize) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, - "Destination array[%d] is not large enough for given copy size: %d", - destSize, - end - start); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Destination array[" + std::to_string(destSize) + + "] is not large enough for given copy size: " + + std::to_string(end - start)); } if (dest == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Destination array is null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Destination array is null"); } System::arraycopy(impl->value.get(), start, dest, destStart, end - start); @@ -1023,18 +1004,16 @@ void AbstractStringBuilder::setCharAt(int index, char value) { if (index < 0) { - throw ArrayIndexOutOfBoundsException(__FILE__, - __LINE__, - "Index < 0: %d", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index < 0: " + std::to_string(index)); } if (index > impl->length) { - throw ArrayIndexOutOfBoundsException(__FILE__, - __LINE__, - "Index > length(): %d", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index > length(): " + std::to_string(index)); } if (impl->shared) @@ -1051,10 +1030,9 @@ void AbstractStringBuilder::setLength(int length) { if (length < 0) { - throw StringIndexOutOfBoundsException(__FILE__, - __LINE__, - "length < 0: %d", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length < 0: " + std::to_string(length)); } if (length > impl->value.length() - 1) @@ -1102,7 +1080,9 @@ String AbstractStringBuilder::substring(int start) const // Remove String sharing for more performance return String(impl->value.get(), start, impl->length - start); } - throw StringIndexOutOfBoundsException(__FILE__, __LINE__, start); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid start index: " + std::to_string(start)); } //////////////////////////////////////////////////////////////////////////////// @@ -1119,12 +1099,10 @@ String AbstractStringBuilder::substring(int start, int end) const return String(impl->value.get(), start, end - start); } - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, - "Start [%d] or end [%d] index value are invalid.", - start, - end); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Start [" + std::to_string(start) + "] or end [" + std::to_string(end) + + "] index value are invalid."); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/decaf/lang/AbstractStringBuilder.h b/activemq-cpp/src/main/decaf/lang/AbstractStringBuilder.h index ca67b17c3..f23380d7c 100644 --- a/activemq-cpp/src/main/decaf/lang/AbstractStringBuilder.h +++ b/activemq-cpp/src/main/decaf/lang/AbstractStringBuilder.h @@ -22,6 +22,7 @@ #include #include +#include namespace decaf { @@ -80,7 +81,7 @@ namespace lang * The index in this buffer where the character to return is * located. * - * @throws IndexOutOfBoundsException if index < 0 or index >= length(). + * @throws std::out_of_range if index < 0 or index >= length(). */ virtual char charAt(int index) const; @@ -114,8 +115,8 @@ namespace lang * @param destStart * The index in the destination array to start the copy at. * - * @throws NullPointerException if the dst pointer is NULL - * @throws IndexOutOfBoundsException if: + * @throws std::logic_error if the dst pointer is NULL + * @throws std::out_of_range if: * start or end is negative * dstSize or dstStart is negative * start is greater than end @@ -200,7 +201,7 @@ namespace lang * @param length * The new length to give this character buffer * - * @throws IndexOutOfBoundsException if length is less than zero. + * @throws std::out_of_range if length is less than zero. */ virtual void setLength(int length); @@ -213,7 +214,7 @@ namespace lang * @param value * The new char value to assign at the given index. * - * @throws IndexOutOfBoundsException if index is negative or greater + * @throws std::out_of_range if index is negative or greater * than length(). */ virtual void setCharAt(int index, char value); @@ -228,7 +229,7 @@ namespace lang * * @return a new String that is a subset of this character buffer. * - * @throws StringIndexOutOfBoundsException + * @throws std::out_of_range * if start is less than zero, or greater than the length of this * buffer. */ @@ -246,7 +247,7 @@ namespace lang * * @return a new String that is a subset of this character buffer. * - * @throws StringIndexOutOfBoundsException + * @throws std::out_of_range * if start or end is less than zero, or end is greater than the * length of this buffer or start is greater than end. */ @@ -267,7 +268,7 @@ namespace lang * @return a new CharSequence pointer that is a subset of this character * buffer. * - * @throws StringIndexOutOfBoundsException + * @throws std::out_of_range * if start or end is less than zero, or end is greater than the * length of this buffer or start is greater than end. */ @@ -309,7 +310,7 @@ namespace lang * @param value * The C string value to be appended into this buffer. * - * @throws NullPointerException if the pointer is NULL. + * @throws std::logic_error if the pointer is NULL. */ void doAppend(const char* value); @@ -325,8 +326,8 @@ namespace lang * @param length * The number of characters to copy from the given array. * - * @throws NullPointerException if the pointer is NULL. - * @throws IndexOutOfBoundsException if offset or length is negative or + * @throws std::logic_error if the pointer is NULL. + * @throws std::out_of_range if offset or length is negative or * the value of offset + length is greater than the strings length. */ void doAppend(const char* value, int offset, int length); @@ -337,7 +338,7 @@ namespace lang * @param value * The CharSequence value to be appended into this buffer. * - * @throws NullPointerException if the pointer is NULL. + * @throws std::logic_error if the pointer is NULL. */ void doAppend(const CharSequence* value); @@ -353,8 +354,8 @@ namespace lang * @param length * The number of characters to copy from the given CharSequence. * - * @throws NullPointerException if the pointer is NULL. - * @throws IndexOutOfBoundsException if offset or length is negative or + * @throws std::logic_error if the pointer is NULL. + * @throws std::out_of_range if offset or length is negative or * the value of offset + length is greater than the strings length. */ void doAppend(const CharSequence* value, int offset, int length); @@ -455,8 +456,8 @@ namespace lang * @param length * The number of characters to copy from the given array. * - * @throws NullPointerException if the pointer is NULL. - * @throws IndexOutOfBoundsException if index, offset or length is + * @throws std::logic_error if the pointer is NULL. + * @throws std::out_of_range if index, offset or length is * negative or the value of offset + length is greater than the strings * length. */ @@ -470,8 +471,8 @@ namespace lang * @param value * The CharSequence value to be appended into this buffer. * - * @throws NullPointerException if the pointer is NULL. - * @throws IndexOutOfBoundsException if index is negative or greater + * @throws std::logic_error if the pointer is NULL. + * @throws std::out_of_range if index is negative or greater * than length(). */ void doInsert(int index, const CharSequence* value); @@ -492,7 +493,7 @@ namespace lang * The end index in the CharSequence to be inserted into this * Buffer. * - * @throws IndexOutOfBoundsException if index, start or end is negative + * @throws std::out_of_range if index, start or end is negative * or the value of start < end or the end index is greater than the * sequence length. */ @@ -513,7 +514,7 @@ namespace lang * @param value * The new string value to replace the older value. * - * @throws IndexOutOfBoundsException if start is negative, greater than + * @throws std::out_of_range if start is negative, greater than * end or greater than length(). */ void doReplace(int start, int end, const String& value); diff --git a/activemq-cpp/src/main/decaf/lang/Appendable.h b/activemq-cpp/src/main/decaf/lang/Appendable.h index 804257709..5f5ffe6a6 100644 --- a/activemq-cpp/src/main/decaf/lang/Appendable.h +++ b/activemq-cpp/src/main/decaf/lang/Appendable.h @@ -90,7 +90,7 @@ namespace lang * @return a Reference to this Appendable * * @throws Exception if an error occurs. - * @throws IndexOutOfBoundsException start is greater than end, or end + * @throws std::out_of_range start is greater than end, or end * is greater than csq.length() */ virtual Appendable& append(const CharSequence* csq, diff --git a/activemq-cpp/src/main/decaf/lang/ArrayPointer.h b/activemq-cpp/src/main/decaf/lang/ArrayPointer.h old mode 100755 new mode 100644 index 630743ae2..6927dfcea --- a/activemq-cpp/src/main/decaf/lang/ArrayPointer.h +++ b/activemq-cpp/src/main/decaf/lang/ArrayPointer.h @@ -18,16 +18,16 @@ #ifndef _DECAF_LANG_ARRAYPOINTER_H_ #define _DECAF_LANG_ARRAYPOINTER_H_ +#include #include -#include -#include -#include #include #include #include #include #include #include +#include +#include #include #include @@ -89,18 +89,17 @@ namespace lang { if (value != NULL && length <= 0) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Non-NULL array pointer cannot have a size <= zero"); } if (value == NULL && length > 0) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "NULL array pointer cannot have a size > zero"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "NULL array pointer cannot have a size > zero"); } } @@ -441,30 +440,30 @@ namespace lang /** * Dereference Operator, returns a reference to the Contained value. - * This method throws an NullPointerException if the contained value is + * This method throws std::logic_error if the contained value is * NULL. * * @return reference to the contained pointer. * - * @throws NullPointerException if the contained value is Null + * @throws std::logic_error if the contained value is Null */ ReferenceType operator[](int index) { if (this->array->value == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, - "ArrayPointer operator& - Pointee is NULL."); + "ArrayPointer operator[] - Pointee is NULL."); } if (index < 0 || this->array->length <= index) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Array Index %d is out of bounds for this array.", - this->array->length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Array Index " + + std::to_string(this->array->length) + + " is out of bounds for this array."); } return this->array->value[index]; @@ -474,19 +473,19 @@ namespace lang { if (this->array->value == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, - "ArrayPointer operator& - Pointee is NULL."); + "ArrayPointer operator[] - Pointee is NULL."); } if (index < 0 || this->array->length <= index) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Array Index %d is out of bounds for this array.", - this->array->length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Array Index " + + std::to_string(this->array->length) + + " is out of bounds for this array."); } return this->array->value[index]; diff --git a/activemq-cpp/src/main/decaf/lang/Byte.cpp b/activemq-cpp/src/main/decaf/lang/Byte.cpp index c826a17f0..12b89f6a1 100644 --- a/activemq-cpp/src/main/decaf/lang/Byte.cpp +++ b/activemq-cpp/src/main/decaf/lang/Byte.cpp @@ -18,10 +18,12 @@ #include "Byte.h" #include +#include +#include + using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// const unsigned char Byte::MIN_VALUE = 0x7F; @@ -60,9 +62,7 @@ unsigned char Byte::parseByte(const String& s, int radix) unsigned char result = (unsigned char)intValue; if (result != intValue) { - throw NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Byte::parseByte - Not a valid unsigned char encoded string."); } @@ -82,9 +82,7 @@ Byte Byte::decode(const String& value) unsigned char result = (unsigned char)intValue; if (result != intValue) { - throw NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Byte::decode - Not a valid unsigned char encoded string."); } diff --git a/activemq-cpp/src/main/decaf/lang/Byte.h b/activemq-cpp/src/main/decaf/lang/Byte.h index fdfe8c47d..eae249565 100644 --- a/activemq-cpp/src/main/decaf/lang/Byte.h +++ b/activemq-cpp/src/main/decaf/lang/Byte.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -59,7 +58,7 @@ namespace lang * @param value * The string to convert to an unsigned char * - * @throws NumberFormatException if the string is not a valid byte. + * @throws std::invalid_argument if the string is not a valid byte. */ Byte(const String& value); @@ -224,7 +223,7 @@ namespace lang * and/or radix specifier ("0x", "0X", "#", or leading zero) is parsed * as by the Byte::parseByte method with the indicated radix (10, 16, or * 8). This sequence of characters must represent a positive value or a - * NumberFormatException will be thrown. The result is negated if first + * std::invalid_argument will be thrown. The result is negated if first * character of the specified String is the minus sign. No whitespace * characters are permitted in the string. * @@ -246,7 +245,7 @@ namespace lang * the first character may be an ASCII minus sign '-' to indicate a * negative value. The resulting byte value is returned. * - * An exception of type NumberFormatException is thrown if any of the + * An exception of type std::invalid_argument is thrown if any of the * following situations occurs: * * The first argument is null or is a string of length zero. * * The radix is either smaller than Character.MIN_RADIX or larger @@ -264,7 +263,7 @@ namespace lang * * @return the unsigned char represented by the string argument in the * specified radix. - * @throws NumberFormatException - If String does not contain a parsable + * @throws std::invalid_argument - If String does not contain a parsable * unsigned char. */ static unsigned char parseByte(const String& s, int radix); @@ -282,7 +281,7 @@ namespace lang * * @return the converted unsigned char value * - * @throws NumberFormatException if the string is not a unsigned char. + * @throws std::invalid_argument if the string is not a unsigned char. */ static unsigned char parseByte(const String& s); @@ -310,7 +309,7 @@ namespace lang * String to parse as base 10 * * @return new Byte Object wrapping the primitive - * @throws NumberFormatException if the string is not a decimal unsigned + * @throws std::invalid_argument if the string is not a decimal unsigned * char. */ static Byte valueOf(const String& value); @@ -330,7 +329,7 @@ namespace lang * * @return new Byte Object wrapping the primitive * - * @throws NumberFormatException if the string is not a valid unsigned + * @throws std::invalid_argument if the string is not a valid unsigned * char. */ static Byte valueOf(const String& value, int radix); diff --git a/activemq-cpp/src/main/decaf/lang/CharSequence.h b/activemq-cpp/src/main/decaf/lang/CharSequence.h index dd04989ee..5066746c0 100644 --- a/activemq-cpp/src/main/decaf/lang/CharSequence.h +++ b/activemq-cpp/src/main/decaf/lang/CharSequence.h @@ -18,8 +18,8 @@ #ifndef _DECAF_LANG_CHARSEQUENCE_H_ #define _DECAF_LANG_CHARSEQUENCE_H_ -#include #include +#include namespace decaf { @@ -55,7 +55,7 @@ namespace lang * * @return the char at the given position. * - * @throws IndexOutOfBoundsException if index is > than length() or + * @throws std::out_of_range if index is > than length() or * negative */ virtual char charAt(int index) const = 0; @@ -74,7 +74,7 @@ namespace lang * * @return a new CharSequence * - * @throws IndexOutOfBoundsException if start or end > length() or start + * @throws std::out_of_range if start or end > length() or start * or end are negative. */ virtual CharSequence* subSequence(int start, int end) const = 0; diff --git a/activemq-cpp/src/main/decaf/lang/Double.cpp b/activemq-cpp/src/main/decaf/lang/Double.cpp index 7fe37d855..64fda1376 100644 --- a/activemq-cpp/src/main/decaf/lang/Double.cpp +++ b/activemq-cpp/src/main/decaf/lang/Double.cpp @@ -16,16 +16,18 @@ */ #include "Double.h" +#include #include #include #include #include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// DECAF_API const int Double::SIZE = 64; @@ -179,10 +181,8 @@ double Double::parseDouble(const String& value) // Not everything got read, meaning there wasn't just a number here. if (!stream.eof()) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, - "Failed to parse a valid float from input string: %s", + throw activemq::exceptions::InvalidArgumentException( + std::string("Failed to parse a valid double from input string: ") + value.c_str()); } diff --git a/activemq-cpp/src/main/decaf/lang/Double.h b/activemq-cpp/src/main/decaf/lang/Double.h index 168613154..478417de9 100644 --- a/activemq-cpp/src/main/decaf/lang/Double.h +++ b/activemq-cpp/src/main/decaf/lang/Double.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -69,13 +68,13 @@ namespace lang /** * Constructs a new Double and attempts to convert the given string to a * double value, assigning it to the new object is successful or - * throwing a NumberFormatException if the string is not a properly + * throwing a std::invalid_argument if the string is not a properly * formatted double. * * @param value * The string to convert to a primitive type to wrap. * - * @throws NumberFormatException if the string is not a a valid double. + * @throws std::invalid_argument if the string is not a a valid double. */ Double(const String& value); @@ -338,7 +337,7 @@ namespace lang * * @return a double parsed from the passed string * - * @throws NumberFormatException + * @throws std::invalid_argument */ static double parseDouble(const String& value); @@ -430,7 +429,7 @@ namespace lang * * @return a new Double instance wrapping the double parsed from value * - * @throws NumberFormatException on error. + * @throws std::invalid_argument on error. */ static Double valueOf(const String& value); diff --git a/activemq-cpp/src/main/decaf/lang/Float.cpp b/activemq-cpp/src/main/decaf/lang/Float.cpp index 703f76a62..05e519db3 100644 --- a/activemq-cpp/src/main/decaf/lang/Float.cpp +++ b/activemq-cpp/src/main/decaf/lang/Float.cpp @@ -16,15 +16,17 @@ */ #include "Float.h" +#include #include #include #include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// DECAF_API const int Float::SIZE = 32; @@ -183,10 +185,8 @@ float Float::parseFloat(const String& value) // Not everything got read, meaning there wasn't just a number here. if (!stream.eof()) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, - "Failed to parse a valid float from input string: %s", + throw activemq::exceptions::InvalidArgumentException( + std::string("Failed to parse a valid float from input string: ") + value.c_str()); } diff --git a/activemq-cpp/src/main/decaf/lang/Float.h b/activemq-cpp/src/main/decaf/lang/Float.h index 6425300d3..b5b19a2e0 100644 --- a/activemq-cpp/src/main/decaf/lang/Float.h +++ b/activemq-cpp/src/main/decaf/lang/Float.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -337,7 +336,7 @@ namespace lang * * @return a float parsed from the string * - * @throw NumberFormatException if an error occurs parsing the String. + * @throw std::invalid_argument if an error occurs parsing the String. */ static float parseFloat(const String& value); @@ -426,7 +425,7 @@ namespace lang * * @param value - the string to parse * @return a new Float instance wrapping the float parsed from value - * @throws NumberFormatException on error. + * @throws std::invalid_argument on error. */ static Float valueOf(const String& value); diff --git a/activemq-cpp/src/main/decaf/lang/Integer.cpp b/activemq-cpp/src/main/decaf/lang/Integer.cpp index dd69602fb..6cf5bf990 100644 --- a/activemq-cpp/src/main/decaf/lang/Integer.cpp +++ b/activemq-cpp/src/main/decaf/lang/Integer.cpp @@ -19,14 +19,16 @@ #pragma warning(disable : 4146) #endif +#include #include #include #include +#include +#include #include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// DECAF_API const int Integer::SIZE = 32; @@ -287,26 +289,22 @@ int Integer::parseInt(const String& value, int radix) { if (radix < Character::MIN_RADIX || radix > Character::MAX_RADIX) { - throw NumberFormatException(__FILE__, - __LINE__, - "Integer:decode - Invalid radix"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Integer:decode - Invalid radix"); } int length = (int)value.length(), i = 0; if (length == 0) { - throw NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Integer:decode - Invalid: zero length string"); } bool negative = value.charAt(i) == '-'; if (negative && ++i == length) { - throw NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Integer:decode - Invalid only a minus sign given"); } @@ -331,9 +329,7 @@ Integer Integer::decode(const String& value) int length = (int)value.length(), i = 0; if (length == 0) { - throw NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Integer:decode - Invalid zero size string"); } @@ -343,9 +339,7 @@ Integer Integer::decode(const String& value) { if (length == 1) { - throw NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Integer:decode - Invalid zero string, minus only"); } @@ -364,9 +358,7 @@ Integer Integer::decode(const String& value) { if (i == length) { - throw NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Integer:decode - Invalid zero string, minus only"); } i++; @@ -381,9 +373,7 @@ Integer Integer::decode(const String& value) { if (i == length) { - throw NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Integer:decode - Invalid zero string, minus only"); } i++; @@ -405,27 +395,21 @@ int Integer::parse(const String& value, int offset, int radix, bool negative) int digit = Character::digit(value.charAt(offset++), radix); if (digit == -1) { - throw NumberFormatException( - __FILE__, - __LINE__, - "Integer::parse - number string is invalid: ", + throw activemq::exceptions::NumberFormatException( + std::string("Integer::parse - number string is invalid: ") + value.c_str()); } if (max > result) { - throw NumberFormatException( - __FILE__, - __LINE__, - "Integer::parse - number string is invalid: ", + throw activemq::exceptions::NumberFormatException( + std::string("Integer::parse - number string is invalid: ") + value.c_str()); } int next = result * radix - digit; if (next > result) { - throw NumberFormatException( - __FILE__, - __LINE__, - "Integer::parse - number string is invalid: ", + throw activemq::exceptions::NumberFormatException( + std::string("Integer::parse - number string is invalid: ") + value.c_str()); } result = next; @@ -435,10 +419,8 @@ int Integer::parse(const String& value, int offset, int radix, bool negative) result = -result; if (result < 0) { - throw NumberFormatException( - __FILE__, - __LINE__, - "Integer::parse - number string is invalid: ", + throw activemq::exceptions::NumberFormatException( + std::string("Integer::parse - number string is invalid: ") + value.c_str()); } } diff --git a/activemq-cpp/src/main/decaf/lang/Integer.h b/activemq-cpp/src/main/decaf/lang/Integer.h index 107d08f2b..f3104a075 100644 --- a/activemq-cpp/src/main/decaf/lang/Integer.h +++ b/activemq-cpp/src/main/decaf/lang/Integer.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -58,13 +57,13 @@ namespace lang /** * Constructs a new Integer and attempts to convert the given string to * an int value, assigning it to the new object is successful or - * throwing a NumberFormatException if the string is not a properly + * throwing a std::invalid_argument if the string is not a properly * formatted int. * * @param value * The string to convert to a primitive type to wrap. * - * @throws NumberFormatException if the string is not a a valid integer. + * @throws std::invalid_argument if the string is not a a valid integer. */ Integer(const std::string& value); @@ -220,7 +219,7 @@ namespace lang * and/or radix specifier ("0x", "0X", "#", or leading zero) is parsed * as by the Integer.parseInteger method with the indicated radix (10, * 16, or 8). This sequence of characters must represent a positive - * value or a NumberFormatException will be thrown. The result is + * value or a std::invalid_argument will be thrown. The result is * negated if first character of the specified String is the minus sign. * No whitespace characters are permitted in the string. * @param value - The string to decode @@ -254,7 +253,7 @@ namespace lang * the first character may be an ASCII minus sign '-' to indicate a * negative value. The resulting byte value is returned. * - * An exception of type NumberFormatException is thrown if any of the + * An exception of type std::invalid_argument is thrown if any of the * following situations occurs: * * The first argument is null or is a string of length zero. * * The radix is either smaller than Character.MIN_RADIX or larger @@ -268,7 +267,7 @@ namespace lang * @param radix - the radix to be used while parsing s * @return the int represented by the string argument in the specified * radix. - * @throws NumberFormatException - If String does not contain a parsable + * @throws std::invalid_argument - If String does not contain a parsable * int. */ static int parseInt(const String& s, int radix); @@ -285,7 +284,7 @@ namespace lang * String to convert to a int * * @return the converted int value - * @throws NumberFormatException if the string is not a int. + * @throws std::invalid_argument if the string is not a int. */ static int parseInt(const String& s); @@ -310,7 +309,7 @@ namespace lang * represents the int value specified by the string. * @param value - std::string to parse as base 10 * @return new Integer Object wrapping the primitive - * @throws NumberFormatException if the string is not a decimal int. + * @throws std::invalid_argument if the string is not a decimal int. */ static Integer valueOf(const String& value); @@ -325,7 +324,7 @@ namespace lang * @param value - std::string to parse as base ( radix ) * @param radix - base of the string to parse. * @return new Integer Object wrapping the primitive - * @throws NumberFormatException if the string is not a valid int. + * @throws std::invalid_argument if the string is not a valid int. */ static Integer valueOf(const String& value, int radix); diff --git a/activemq-cpp/src/main/decaf/lang/Long.cpp b/activemq-cpp/src/main/decaf/lang/Long.cpp index 1d31388da..0efa9b580 100644 --- a/activemq-cpp/src/main/decaf/lang/Long.cpp +++ b/activemq-cpp/src/main/decaf/lang/Long.cpp @@ -16,8 +16,11 @@ */ #include "Long.h" +#include #include #include +#include +#include using namespace decaf; using namespace decaf::lang; @@ -85,9 +88,8 @@ Long Long::decode(const String& value) int length = (int)value.length(), i = 0; if (length == 0) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Long::decode - Zero length string given."); } @@ -97,10 +99,8 @@ Long Long::decode(const String& value) { if (length == 1) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, - "Long::decode - Invalid length string given.", + throw activemq::exceptions::NumberFormatException( + std::string("Long::decode - Invalid length string given.") + value.c_str()); } firstDigit = value.charAt(++i); @@ -117,10 +117,8 @@ Long Long::decode(const String& value) { if (i == length) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, - "Long::decode - Invalid length string given.", + throw activemq::exceptions::NumberFormatException( + std::string("Long::decode - Invalid length string given.") + value.c_str()); } i++; @@ -135,10 +133,8 @@ Long Long::decode(const String& value) { if (i == length) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, - "Long::decode - Invalid length string given.", + throw activemq::exceptions::NumberFormatException( + std::string("Long::decode - Invalid length string given.") + value.c_str()); } i++; @@ -222,9 +218,7 @@ long long Long::parseLong(const String& value, int radix) { if (radix < Character::MIN_RADIX || radix > Character::MAX_RADIX) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Long::parseLong - Given Radix is out of range."); } @@ -233,18 +227,14 @@ long long Long::parseLong(const String& value, int radix) if (length == 0) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Long::parseLong - Zero length string is illegal."); } bool negative = value.charAt(i) == '-'; if (negative && ++i == length) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Long::parseLong - Only a minus given, string is invalid."); } @@ -264,17 +254,13 @@ long long Long::parse(const String& value, int offset, int radix, bool negative) if (digit == -1) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Long::parseLong - String contains no digit characters."); } if (max > result) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Long::parseLong - Parsed value greater than max for radix."); } @@ -282,9 +268,7 @@ long long Long::parse(const String& value, int offset, int radix, bool negative) if (next > result) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Long::parseLong - Only a minus given, string is invalid."); } @@ -295,9 +279,7 @@ long long Long::parse(const String& value, int offset, int radix, bool negative) { if (result == Long::MIN_VALUE) { - throw exceptions::NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Long::parseLong - Value less than zero, but no minus sign."); } result = -result; diff --git a/activemq-cpp/src/main/decaf/lang/Long.h b/activemq-cpp/src/main/decaf/lang/Long.h index 5e315ca6a..29a3c61cb 100644 --- a/activemq-cpp/src/main/decaf/lang/Long.h +++ b/activemq-cpp/src/main/decaf/lang/Long.h @@ -21,7 +21,6 @@ #include #include #include -#include #include namespace decaf @@ -56,13 +55,13 @@ namespace lang /** * Constructs a new Long and attempts to convert the given string to an * long long value, assigning it to the new object is successful or - * throwing a NumberFormatException if the string is not a properly + * throwing a std::invalid_argument if the string is not a properly * formatted long long. * * @param value * The string to convert to a primitive type to wrap. * - * @throws NumberFormatException if the string is not a a valid 64bit + * @throws std::invalid_argument if the string is not a a valid 64bit * long. */ Long(const String& value); @@ -227,7 +226,7 @@ namespace lang * and/or radix specifier ("0x", "0X", "#", or leading zero) is parsed * as by the Integer.parseInteger method with the indicated radix (10, * 16, or 8). This sequence of characters must represent a positive - * value or a NumberFormatException will be thrown. The result is + * value or a std::invalid_argument will be thrown. The result is * negated if first character of the specified String is the minus sign. * No whitespace characters are permitted in the string. * @param value - The string to decode @@ -309,7 +308,7 @@ namespace lang * end of this string as would normally be permitted in a C++ program. * @param value - String to parse * @return long long value - * @throws NumberFormatException on invalid string value + * @throws std::invalid_argument on invalid string value */ static long long parseLong(const String& value); @@ -324,7 +323,7 @@ namespace lang * @param value - String to parse * @param radix - the base encoding of the string * @return long long value - * @throws NumberFormatException on invalid string value + * @throws std::invalid_argument on invalid string value */ static long long parseLong(const String& value, int radix); @@ -508,7 +507,7 @@ namespace lang * String to parse as base 10 * * @return new Long Object wrapping the primitive - * @throws NumberFormatException if the string is not a decimal long + * @throws std::invalid_argument if the string is not a decimal long * long. */ static Long valueOf(const String& value); @@ -528,7 +527,7 @@ namespace lang * base of the string to parse. * * @return new Long Object wrapping the primitive - * @throws NumberFormatException if the string is not a valid long long. + * @throws std::invalid_argument if the string is not a valid long long. */ static Long valueOf(const String& value, int radix); diff --git a/activemq-cpp/src/main/decaf/lang/Pointer.h b/activemq-cpp/src/main/decaf/lang/Pointer.h index 326ba2701..fd9fd764d 100644 --- a/activemq-cpp/src/main/decaf/lang/Pointer.h +++ b/activemq-cpp/src/main/decaf/lang/Pointer.h @@ -15,17 +15,18 @@ * limitations under the License. */ +#include #ifndef _DECAF_LANG_POINTER_H_ #define _DECAF_LANG_POINTER_H_ -#include -#include #include #include #include #include #include #include +#include +#include #include namespace decaf @@ -154,13 +155,13 @@ namespace lang * Dynamic Cast constructor. Copies the value contained in the pointer * to the new instance and increments the reference counter performing a * dynamic cast on the value contained in the source Pointer object. If - * the cast fails and return NULL then this method throws a - * ClassCastException. + * the cast fails and return NULL then this method throws + * std::bad_cast. * * @param value * Pointer instance to cast to this type using a dynamic_cast. * - * @throw ClassCastException if the dynamic cast returns NULL + * @throw std::bad_cast if the dynamic cast returns NULL */ template Pointer(const Pointer& value, const DYNAMIC_CAST_TOKEN&) @@ -174,13 +175,7 @@ namespace lang // since we didn't actually create one as the dynamic cast // failed. REFCOUNTER::release(); - throw decaf::lang::exceptions::ClassCastException( - __FILE__, - __LINE__, - "Failed to cast source pointer of type %s to this type: " - "%s.", - typeid(T1).name(), - typeid(T).name()); + throw std::bad_cast(); } } @@ -282,17 +277,19 @@ namespace lang /** * Dereference Operator, returns a reference to the Contained value. - * This method throws an NullPointerException if the contained value is - * NULL. + * This method throws + * activemq::exceptions::IllegalStateException if the contained + * value is NULL. * * @return reference to the contained pointer. - * @throws NullPointerException if the contained value is Null + * @throws activemq::exceptions::IllegalStateException if the + * contained value is Null */ ReferenceType operator*() { if (this->value == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Pointer operator& - Pointee is NULL."); @@ -305,7 +302,7 @@ namespace lang { if (this->value == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Pointer operator& - Pointee is NULL."); @@ -316,16 +313,18 @@ namespace lang /** * Indirection Operator, returns a pointer to the Contained value. This - * method throws an NullPointerException if the contained value is NULL. + * method throws activemq::exceptions::IllegalStateException if + * the contained value is NULL. * * @return reference to the contained pointer. - * @throws NullPointerException if the contained value is Null + * @throws activemq::exceptions::IllegalStateException if the + * contained value is Null */ PointerType operator->() { if (this->value == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Pointer operator-> - Pointee is NULL."); @@ -337,7 +336,7 @@ namespace lang { if (this->value == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Pointer operator-> - Pointee is NULL."); diff --git a/activemq-cpp/src/main/decaf/lang/Readable.h b/activemq-cpp/src/main/decaf/lang/Readable.h index fe39b4a7c..741406e3f 100644 --- a/activemq-cpp/src/main/decaf/lang/Readable.h +++ b/activemq-cpp/src/main/decaf/lang/Readable.h @@ -21,7 +21,6 @@ #include #include -#include #include namespace decaf @@ -58,7 +57,7 @@ namespace lang * source of characters is at its end * * @throws IOException if an I/O error occurs. - * @throws NullPointerException if buffer is NULL. + * @throws std::logic_error if buffer is NULL. * @throws ReadOnlyBufferException if charBuffer is a read only buffer. */ virtual int read(decaf::nio::CharBuffer* charBuffer) = 0; diff --git a/activemq-cpp/src/main/decaf/lang/Short.cpp b/activemq-cpp/src/main/decaf/lang/Short.cpp index dbd1208a9..229943a3b 100644 --- a/activemq-cpp/src/main/decaf/lang/Short.cpp +++ b/activemq-cpp/src/main/decaf/lang/Short.cpp @@ -18,11 +18,12 @@ #include "Short.h" #include "Integer.h" +#include #include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// DECAF_API const int Short::SIZE = 16; @@ -78,9 +79,7 @@ short Short::parseShort(const String& s, int radix) short result = (short)intValue; if (result != intValue) { - throw NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Short::parseShort - Not a valid short encoded string."); } @@ -100,9 +99,7 @@ Short Short::decode(const String& value) short result = (short)intValue; if (result != intValue) { - throw NumberFormatException( - __FILE__, - __LINE__, + throw activemq::exceptions::NumberFormatException( "Short::decode - Not a valid short encoded string."); } diff --git a/activemq-cpp/src/main/decaf/lang/Short.h b/activemq-cpp/src/main/decaf/lang/Short.h index 4563b1da2..53d064233 100644 --- a/activemq-cpp/src/main/decaf/lang/Short.h +++ b/activemq-cpp/src/main/decaf/lang/Short.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -58,7 +57,7 @@ namespace lang * @param value * The string value to convert to short and wrap. * - * @throws NumberFormatException if the string is not well formed number + * @throws std::invalid_argument if the string is not well formed number * value. */ Short(const String& value); @@ -216,7 +215,7 @@ namespace lang * and/or radix specifier ("0x", "0X", "#", or leading zero) is parsed * as by the Short.parseShort method with the indicated radix (10, 16, * or 8). This sequence of characters must represent a positive value or - * a NumberFormatException will be thrown. The result is negated if + * a std::invalid_argument will be thrown. The result is negated if * first character of the specified String is the minus sign. No * whitespace characters are permitted in the string. * @param value - The string to decode @@ -241,7 +240,7 @@ namespace lang * Character.digit(char, int) returns a nonnegative value) except that * the first character may be an ASCII minus sign '-' to indicate a * negative value. The resulting byte value is returned.

An - * exception of type NumberFormatException is thrown if any of the + * exception of type std::invalid_argument is thrown if any of the * following situations occurs: * * The first argument is null or is a string of length zero. * * The radix is either smaller than Character.MIN_RADIX or larger @@ -259,7 +258,7 @@ namespace lang * @return the short represented by the string argument in the specified * radix. * - * @throws NumberFormatException - If String does not contain a parsable + * @throws std::invalid_argument - If String does not contain a parsable * short. */ static short parseShort(const String& s, int radix); @@ -277,7 +276,7 @@ namespace lang * * @return the converted short value * - * @throws NumberFormatException if the string is not a short. + * @throws std::invalid_argument if the string is not a short. */ static short parseShort(const String& s); @@ -300,7 +299,7 @@ namespace lang * * @return new Short Object wrapping the primitive * - * @throws NumberFormatException if the string is not a decimal short. + * @throws std::invalid_argument if the string is not a decimal short. */ static Short valueOf(const String& value); @@ -320,7 +319,7 @@ namespace lang * * @return new Short Object wrapping the primitive * - * @throws NumberFormatException if the string is not a valid short. + * @throws std::invalid_argument if the string is not a valid short. */ static Short valueOf(const String& value, int radix); }; diff --git a/activemq-cpp/src/main/decaf/lang/String.cpp b/activemq-cpp/src/main/decaf/lang/String.cpp index 52971e12c..86ce79419 100644 --- a/activemq-cpp/src/main/decaf/lang/String.cpp +++ b/activemq-cpp/src/main/decaf/lang/String.cpp @@ -25,16 +25,15 @@ #include #include #include -#include -#include -#include +#include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::util; @@ -118,11 +117,9 @@ String::String(const char value, int count) { if (count < 0) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, - "count parameter out of Bounds: %d.", - count); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "count parameter out of Bounds: " + std::to_string(count) + "."); } contents = new Contents(count); @@ -156,9 +153,10 @@ String::String(const char* array) { if (array == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer pointer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer pointer passed was NULL."); } int size = StringUtils::stringLength(array); @@ -180,18 +178,17 @@ String::String(const char* array, int size) { if (size < 0) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (array == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer pointer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer pointer passed was NULL."); } if (size > 0) @@ -209,31 +206,28 @@ String::String(const char* array, int size) String::String(const char* array, int offset, int length) : contents() { - int size = StringUtils::stringLength(array); - - if (offset > size || offset < 0) + if (array == NULL) { - throw StringIndexOutOfBoundsException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, - "offset parameter out of Bounds: %d.", - offset); + "Buffer pointer passed was NULL."); } - if (length < 0 || length > size - offset) + int size = StringUtils::stringLength(array); + + if (offset > size || offset < 0) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + "."); } - if (array == NULL) + if (length < 0 || length > size - offset) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer pointer passed was NULL."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + "."); } if (size > 0 && length > 0) @@ -253,35 +247,31 @@ String::String(const char* array, int size, int offset, int length) { if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + "."); } if (length < 0 || length > size - offset) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + "."); } if (array == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer pointer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer pointer passed was NULL."); } if (size > 0 && length > 0) @@ -341,9 +331,10 @@ String& String::operator=(const char* other) { if (other == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Assignment from NULL not supported."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Assignment from NULL not supported."); } int length = StringUtils::stringLength(other); @@ -522,17 +513,23 @@ char String::charAt(int index) const { if (index < 0 || index >= this->length()) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index given is out of bounds: %d.", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index given is out of bounds: " + std::to_string(index) + "."); } return this->contents->value[this->contents->offset + index]; } - DECAF_CATCH_RETHROW(StringIndexOutOfBoundsException) - DECAF_CATCHALL_THROW(StringIndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -605,9 +602,10 @@ int String::compareTo(const char* string) const { if (string == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Comparison C String cannot be NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Comparison C String cannot be NULL"); } int length = StringUtils::stringLength(string); @@ -693,9 +691,10 @@ int String::compareToIgnoreCase(const char* string) const { if (string == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Comparison C String cannot be NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Comparison C String cannot be NULL"); } int length = StringUtils::stringLength(string); @@ -730,9 +729,10 @@ String String::copyValueOf(const char* data) { if (data == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "C String to be copied cannot be NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "C String to be copied cannot be NULL"); } return String(data, 0, StringUtils::stringLength(data)); @@ -743,9 +743,10 @@ String String::copyValueOf(char* data, int start, int length) { if (data == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "C String to be copied cannot be NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "C String to be copied cannot be NULL"); } return String(data, start, length); @@ -1124,30 +1125,27 @@ void String::getChars(int srcBegin, { if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > contents->length) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, - "Invalid start or end parameters: %d, %d", - srcBegin, - srcEnd); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid start or end parameters: " + std::to_string(srcBegin) + + ", " + std::to_string(srcEnd)); } if (destSize < 0 || destBegin < 0 || (destBegin + (srcEnd - srcBegin)) > destSize) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, - "Invalid destination size or offset parameters: %d, %d", - destSize, - destBegin); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid destination size or offset parameters: " + + std::to_string(destSize) + ", " + std::to_string(destBegin)); } if (dest == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Destination pointer was Null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Destination pointer was Null"); } // Note: last character not copied! @@ -1724,7 +1722,9 @@ String String::substring(int start) const contents->value); } - throw StringIndexOutOfBoundsException(__FILE__, __LINE__, start); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid start index: " + std::to_string(start)); } //////////////////////////////////////////////////////////////////////////////// @@ -1737,15 +1737,21 @@ String String::substring(int start, int end) const if (start < 0) { - throw StringIndexOutOfBoundsException(__FILE__, __LINE__, start); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid start index: " + std::to_string(start)); } else if (start > end) { - throw StringIndexOutOfBoundsException(__FILE__, __LINE__, end - start); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid length: " + std::to_string(end - start)); } else if (end > contents->length) { - throw StringIndexOutOfBoundsException(__FILE__, __LINE__, end); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid end index: " + std::to_string(end)); } // NOTE last character not copied! @@ -1760,24 +1766,30 @@ CharSequence* String::subSequence(int start DECAF_UNUSED, { if (start > end) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Start index is greater than end index."); } if (end - start > this->length()) { - throw StringIndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Requested Range is greater than the String length."); } return NULL; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/decaf/lang/String.h b/activemq-cpp/src/main/decaf/lang/String.h index 7efdb7571..d56fd6025 100644 --- a/activemq-cpp/src/main/decaf/lang/String.h +++ b/activemq-cpp/src/main/decaf/lang/String.h @@ -25,6 +25,7 @@ #include #include +#include #include namespace decaf @@ -79,7 +80,7 @@ namespace lang * @param count * The number of copies of the character to fill. * - * @throws IndexOutOfBoundsException if the count parameter is negative. + * @throws std::out_of_range if the count parameter is negative. */ String(const char value, int count); @@ -108,7 +109,7 @@ namespace lang * @param array * The character buffer to copy into this new String object. * - * @throws NullPointerException if the character array parameter is + * @throws std::logic_error if the character array parameter is * NULL. */ String(const char* array); @@ -126,9 +127,9 @@ namespace lang * The size of the string buffer given, in case the string is not * NULL terminated. * - * @throws NullPointerException if the character array parameter is + * @throws std::logic_error if the character array parameter is * NULL. - * @throws IndexOutOfBoundsException if the size parameter is negative. + * @throws std::out_of_range if the size parameter is negative. */ String(const char* array, int size); @@ -146,9 +147,9 @@ namespace lang * The number of bytes to copy from the given buffer starting from * the offset. * - * @throws NullPointerException if the character array parameter is + * @throws std::logic_error if the character array parameter is * NULL. - * @throws IndexOutOfBoundsException if the size, offset or length + * @throws std::out_of_range if the size, offset or length * parameter is negative or if the length to copy is greater than the * span of size - offset. */ @@ -172,9 +173,9 @@ namespace lang * The number of bytes to copy from the given buffer starting from * the offset. * - * @throws NullPointerException if the character array parameter is + * @throws std::logic_error if the character array parameter is * NULL. - * @throws IndexOutOfBoundsException if the size, offset or length + * @throws std::out_of_range if the size, offset or length * parameter is negative or if the length to copy is greater than the * span of size - offset. */ @@ -411,7 +412,7 @@ namespace lang * is before the specified string, or a positive integer if this string * is after the specified string. * - * @throws NullPointerException if the passed in C String value is NULL. + * @throws std::logic_error if the passed in C String value is NULL. */ int compareTo(const char* string) const; @@ -461,7 +462,7 @@ namespace lang * is before the specified string, or a positive integer if this string * is after the specified string. * - * @throws NullPointerException if the passed in C String value is NULL. + * @throws std::logic_error if the passed in C String value is NULL. */ int compareToIgnoreCase(const char* string) const; @@ -696,7 +697,7 @@ namespace lang * @param destBegin * The offset into the destination array to start copying to. * - * @throws IndexOutOfBoundsException if any of the following conditions + * @throws std::out_of_range if any of the following conditions * are met: srcBegin or srcEnd are negative. srcBegin is greater than * src end. srcEnd is greater than the length() destSize or destBegin * are negative. destBegin + (srcEnd - srcBegin) is greater than @@ -1048,7 +1049,7 @@ namespace lang * @return a new string containing the characters from start to the end * of the string. * - * @throws IndexOutOfBoundsException if start < 0 or start > length(). + * @throws std::out_of_range if start < 0 or start > length(). */ String substring(int start) const; @@ -1064,7 +1065,7 @@ namespace lang * * @return a new string containing the characters from start to end - 1. * - * @throws IndexOutOfBoundsException if start < 0, start > end or end > + * @throws std::out_of_range if start < 0, start > end or end > * length(). */ String substring(int start, int end) const; @@ -1142,7 +1143,7 @@ namespace lang * * @return the new string. * - * @throws NullPointerException if the C string pointer is NULL + * @throws std::logic_error if the C string pointer is NULL */ static String copyValueOf(const char* data); @@ -1160,8 +1161,8 @@ namespace lang * * @return the new string. * - * @throws NullPointerException if the C string is NULL - * @throws IndexOutOfBoundsException + * @throws std::logic_error if the C string is NULL + * @throws std::out_of_range * if length < 0, start < 0 or start + length > the C string's * length. */ diff --git a/activemq-cpp/src/main/decaf/lang/StringBuffer.cpp b/activemq-cpp/src/main/decaf/lang/StringBuffer.cpp index e5d2d9bd3..c2c5f29c3 100644 --- a/activemq-cpp/src/main/decaf/lang/StringBuffer.cpp +++ b/activemq-cpp/src/main/decaf/lang/StringBuffer.cpp @@ -17,19 +17,16 @@ #include -#include -#include - #include #include #include #include #include #include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// StringBuffer::StringBuffer() diff --git a/activemq-cpp/src/main/decaf/lang/StringBuffer.h b/activemq-cpp/src/main/decaf/lang/StringBuffer.h index a74c0f59f..dd6120e87 100644 --- a/activemq-cpp/src/main/decaf/lang/StringBuffer.h +++ b/activemq-cpp/src/main/decaf/lang/StringBuffer.h @@ -25,6 +25,7 @@ #include #include #include +#include namespace decaf { @@ -73,7 +74,7 @@ namespace lang * @param capacity * The initial capacity to give this new instance. * - * @throws NegativeArraySizeException if the given capacity is less than + * @throws std::runtime_error if the given capacity is less than * zero. */ StringBuffer(int capacity); @@ -98,7 +99,7 @@ namespace lang * The CharSequence whose contents are to be copied into this * StringBuffer. * - * @throws NullPointerException if the CharSequence pointer is NULL. + * @throws std::logic_error if the CharSequence pointer is NULL. */ StringBuffer(const CharSequence* source); @@ -292,8 +293,8 @@ namespace lang * @param length * The number of characters to copy from the given array. * - * @throws NullPointerException if the pointer is NULL. - * @throws IndexOutOfBoundsException if offset or length is negative or + * @throws std::logic_error if the pointer is NULL. + * @throws std::out_of_range if offset or length is negative or * the value of offset + length is greater than the strings length. */ StringBuffer& append(const char* value, int offset, int length); @@ -324,7 +325,7 @@ namespace lang * @param length * The number of characters to copy from the given CharSequence. * - * @throws IndexOutOfBoundsException if offset or length is negative or + * @throws std::out_of_range if offset or length is negative or * the value of offset + length is greater than the strings length. */ StringBuffer& append(const CharSequence* value, int offset, int length); @@ -366,7 +367,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws StringIndexOutOfBoundsException + * @throws std::out_of_range * if start is negative, greater than length(), or greater than * end. */ @@ -383,7 +384,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws StringIndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& deleteCharAt(int index); @@ -457,7 +458,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& insert(int index, char value); @@ -475,7 +476,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& insert(int index, bool value); @@ -493,7 +494,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& insert(int index, short value); @@ -511,7 +512,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& insert(int index, int value); @@ -529,7 +530,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& insert(int index, long long value); @@ -547,7 +548,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& insert(int index, float value); @@ -565,7 +566,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& insert(int index, double value); @@ -582,8 +583,8 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws NullPointerException if the target C string pointer is NULL. - * @throws IndexOutOfBoundsException + * @throws std::logic_error if the target C string pointer is NULL. + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& insert(int index, const char* value); @@ -600,8 +601,8 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws NullPointerException if the target C string pointer is NULL. - * @throws IndexOutOfBoundsException + * @throws std::logic_error if the target C string pointer is NULL. + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& insert(int index, const String& value); @@ -618,9 +619,9 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws NullPointerException if the target std::string pointer is + * @throws std::logic_error if the target std::string pointer is * NULL. - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& insert(int index, const std::string& value); @@ -642,8 +643,8 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws NullPointerException if the target C string pointer is NULL. - * @throws IndexOutOfBoundsException + * @throws std::logic_error if the target C string pointer is NULL. + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). * If offset or length is negative or offset > the string length + * length. @@ -668,7 +669,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuffer& insert(int index, const CharSequence* value); @@ -692,7 +693,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). * If offset or length is negative or offset > the string length + * length. @@ -720,7 +721,7 @@ namespace lang * @return a reference to this StringBuffer so that operations can be * chained. * - * @throws IndexOutOfBoundsException if start is negative, greater than + * @throws std::out_of_range if start is negative, greater than * end or greater than length(). */ StringBuffer& replace(int start, int end, const String& value); diff --git a/activemq-cpp/src/main/decaf/lang/StringBuilder.cpp b/activemq-cpp/src/main/decaf/lang/StringBuilder.cpp index bdca48d4a..45d348ec7 100644 --- a/activemq-cpp/src/main/decaf/lang/StringBuilder.cpp +++ b/activemq-cpp/src/main/decaf/lang/StringBuilder.cpp @@ -17,19 +17,16 @@ #include -#include -#include - #include #include #include #include #include #include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// StringBuilder::StringBuilder() diff --git a/activemq-cpp/src/main/decaf/lang/StringBuilder.h b/activemq-cpp/src/main/decaf/lang/StringBuilder.h index be6a045d6..1028fddc2 100644 --- a/activemq-cpp/src/main/decaf/lang/StringBuilder.h +++ b/activemq-cpp/src/main/decaf/lang/StringBuilder.h @@ -24,6 +24,7 @@ #include #include #include +#include namespace decaf { @@ -67,7 +68,7 @@ namespace lang * @param capacity * The initial capacity to give this new instance. * - * @throws NegativeArraySizeException if the given capacity is less than + * @throws std::runtime_error if the given capacity is less than * zero. */ StringBuilder(int capacity); @@ -92,7 +93,7 @@ namespace lang * The CharSequence whose contents are to be copied into this * StringBuilder. * - * @throws NullPointerException if the CharSequence pointer is NULL. + * @throws std::logic_error if the CharSequence pointer is NULL. */ StringBuilder(const CharSequence* source); @@ -251,8 +252,8 @@ namespace lang * @param length * The number of characters to copy from the given array. * - * @throws NullPointerException if the pointer is NULL. - * @throws IndexOutOfBoundsException if offset or length is negative or + * @throws std::logic_error if the pointer is NULL. + * @throws std::out_of_range if offset or length is negative or * the value of offset + length is greater than the strings length. */ StringBuilder& append(const char* value, int offset, int length); @@ -283,7 +284,7 @@ namespace lang * @param length * The number of characters to copy from the given CharSequence. * - * @throws IndexOutOfBoundsException if offset or length is negative or + * @throws std::out_of_range if offset or length is negative or * the value of offset + length is greater than the strings length. */ StringBuilder& append(const CharSequence* value, @@ -327,7 +328,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws StringIndexOutOfBoundsException + * @throws std::out_of_range * if start is negative, greater than length(), or greater than * end. */ @@ -344,7 +345,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws StringIndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& deleteCharAt(int index); @@ -418,7 +419,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& insert(int index, char value); @@ -436,7 +437,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& insert(int index, bool value); @@ -454,7 +455,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& insert(int index, short value); @@ -472,7 +473,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& insert(int index, int value); @@ -490,7 +491,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& insert(int index, long long value); @@ -508,7 +509,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& insert(int index, float value); @@ -526,7 +527,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& insert(int index, double value); @@ -543,8 +544,8 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws NullPointerException if the target C string pointer is NULL. - * @throws IndexOutOfBoundsException + * @throws std::logic_error if the target C string pointer is NULL. + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& insert(int index, const char* value); @@ -561,8 +562,8 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws NullPointerException if the target C string pointer is NULL. - * @throws IndexOutOfBoundsException + * @throws std::logic_error if the target C string pointer is NULL. + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& insert(int index, const String& value); @@ -579,9 +580,9 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws NullPointerException if the target std::string pointer is + * @throws std::logic_error if the target std::string pointer is * NULL. - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& insert(int index, const std::string& value); @@ -603,8 +604,8 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws NullPointerException if the target C string pointer is NULL. - * @throws IndexOutOfBoundsException + * @throws std::logic_error if the target C string pointer is NULL. + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). * If offset or length is negative or offset > the string length + * length. @@ -629,7 +630,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). */ StringBuilder& insert(int index, const CharSequence* value); @@ -653,7 +654,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws IndexOutOfBoundsException + * @throws std::out_of_range * if the index is negative or greater than or equal to length(). * If offset or length is negative or offset > the string length + * length. @@ -681,7 +682,7 @@ namespace lang * @return a reference to this StringBuilder so that operations can be * chained. * - * @throws IndexOutOfBoundsException if start is negative, greater than + * @throws std::out_of_range if start is negative, greater than * end or greater than length(). */ StringBuilder& replace(int start, int end, const String& value); diff --git a/activemq-cpp/src/main/decaf/lang/System.cpp b/activemq-cpp/src/main/decaf/lang/System.cpp index 85b5dc829..d007eeafa 100644 --- a/activemq-cpp/src/main/decaf/lang/System.cpp +++ b/activemq-cpp/src/main/decaf/lang/System.cpp @@ -17,9 +17,8 @@ #include "System.h" -#include -#include -#include +#include +#include #include #include #include @@ -27,6 +26,8 @@ #include #include #include +#include +#include #ifdef _WIN32 #include // For _putenv_s on Windows @@ -66,6 +67,7 @@ #include #include +#include using namespace std; using namespace decaf; @@ -73,7 +75,6 @@ using namespace decaf::lang; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::internal; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace decaf @@ -135,16 +136,18 @@ void System::arraycopy(const char* src, { if (src == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } - if (src == NULL) + if (dest == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } // Now we try and copy, could still segfault. @@ -167,16 +170,18 @@ void System::arraycopy(const unsigned char* src, { if (src == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } - if (src == NULL) + if (dest == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } // Now we try and copy, could still segfault. @@ -199,16 +204,18 @@ void System::arraycopy(const short* src, { if (src == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } - if (src == NULL) + if (dest == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } // Now we try and copy, could still segfault. @@ -231,16 +238,18 @@ void System::arraycopy(const int* src, { if (src == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } - if (src == NULL) + if (dest == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } // Now we try and copy, could still segfault. @@ -263,16 +272,18 @@ void System::arraycopy(const long long* src, { if (src == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } - if (src == NULL) + if (dest == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } // Now we try and copy, could still segfault. @@ -295,16 +306,18 @@ void System::arraycopy(const float* src, { if (src == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } - if (src == NULL) + if (dest == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } // Now we try and copy, could still segfault. @@ -327,16 +340,18 @@ void System::arraycopy(const double* src, { if (src == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } - if (src == NULL) + if (dest == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Given Source Pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Given Source Pointer was null."); } // Now we try and copy, could still segfault. @@ -357,21 +372,23 @@ void System::unsetenv(const std::string& name) // On Windows, setting to empty string effectively unsets the variable if (_putenv_s(name.c_str(), "") != 0) { - throw RuntimeException( + throw activemq::exceptions::RuntimeException( __FILE__, __LINE__, - "System::unsetenv - Failed to unset environment variable: %s", - name.c_str()); + std::string( + "System::unsetenv - Failed to unset environment variable: ") + + name); } #else // POSIX systems have unsetenv if (::unsetenv(name.c_str()) != 0) { - throw RuntimeException( + throw activemq::exceptions::RuntimeException( __FILE__, __LINE__, - "System::unsetenv - Failed to unset environment variable: %s", - name.c_str()); + std::string( + "System::unsetenv - Failed to unset environment variable: ") + + name); } #endif } @@ -383,11 +400,11 @@ std::string System::getenv(const std::string& name) if (value == nullptr) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, - "System::getenv - Environment variable not found: %s", - name.c_str()); + std::string("System::getenv - Environment variable not found: ") + + name); } return std::string(value); @@ -399,21 +416,23 @@ void System::setenv(const std::string& name, const std::string& value) #ifdef _WIN32 if (_putenv_s(name.c_str(), value.c_str()) != 0) { - throw RuntimeException( + throw activemq::exceptions::RuntimeException( __FILE__, __LINE__, - "System::setenv - Failed to set environment variable: %s", - name.c_str()); + std::string( + "System::setenv - Failed to set environment variable: ") + + name); } #else // POSIX setenv: 1 means overwrite existing value if (::setenv(name.c_str(), value.c_str(), 1) != 0) { - throw RuntimeException( + throw activemq::exceptions::RuntimeException( __FILE__, __LINE__, - "System::setenv - Failed to set environment variable: %s", - name.c_str()); + std::string( + "System::setenv - Failed to set environment variable: ") + + name); } #endif } @@ -472,11 +491,9 @@ const Map& System::getenv() else if (tokens == 0) { // Odd case, got a string with no equals sign. - throw IllegalArgumentException( - __FILE__, - __LINE__, - "System::getenv - Invalid env string. %s", - env[i].c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "System::getenv - Invalid env string. " + env[i]); } else { @@ -533,6 +550,7 @@ std::vector System::getEnvArray() #if defined(__APPLE__) #include +#include #define environ (*_NSGetEnviron()) #else extern char** environ; @@ -604,9 +622,8 @@ std::string System::getProperty(const std::string& key) { if (key.empty()) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Cannot pass an empty key to getProperty."); } @@ -619,9 +636,8 @@ std::string System::getProperty(const std::string& key, { if (key.empty()) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Cannot pass an empty key to getProperty."); } @@ -634,9 +650,8 @@ std::string System::setProperty(const std::string& key, { if (key.empty()) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Cannot pass an empty key to setProperty."); } @@ -653,9 +668,8 @@ std::string System::clearProperty(const std::string& key) { if (key.empty()) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Cannot pass an empty key to clearProperty."); } diff --git a/activemq-cpp/src/main/decaf/lang/System.h b/activemq-cpp/src/main/decaf/lang/System.h index b071d44e7..f5e1bd6e7 100644 --- a/activemq-cpp/src/main/decaf/lang/System.h +++ b/activemq-cpp/src/main/decaf/lang/System.h @@ -15,14 +15,15 @@ * limitations under the License. */ +#include #ifndef _DECAF_LANG_SYSTEM_H_ #define _DECAF_LANG_SYSTEM_H_ #include -#include #include #include #include +#include #include namespace decaf @@ -70,7 +71,8 @@ namespace lang * @param length * The number of elements to copy from src to dest. * - * @throws NullPointerException if src or dest are NULL. + * @throws activemq::exceptions::IllegalStateException if src or + * dest are NULL. */ static void arraycopy(const char* src, std::size_t srcPos, @@ -94,7 +96,8 @@ namespace lang * @param length * The number of elements to copy from src to dest. * - * @throws NullPointerException if src or dest are NULL. + * @throws activemq::exceptions::IllegalStateException if src or + * dest are NULL. */ static void arraycopy(const unsigned char* src, std::size_t srcPos, @@ -118,7 +121,8 @@ namespace lang * @param length * The number of elements to copy from src to dest. * - * @throws NullPointerException if src or dest are NULL. + * @throws activemq::exceptions::IllegalStateException if src or + * dest are NULL. */ static void arraycopy(const short* src, std::size_t srcPos, @@ -142,7 +146,8 @@ namespace lang * @param length * The number of elements to copy from src to dest. * - * @throws NullPointerException if src or dest are NULL. + * @throws activemq::exceptions::IllegalStateException if src or + * dest are NULL. */ static void arraycopy(const int* src, std::size_t srcPos, @@ -166,7 +171,8 @@ namespace lang * @param length * The number of elements to copy from src to dest. * - * @throws NullPointerException if src or dest are NULL. + * @throws activemq::exceptions::IllegalStateException if src or + * dest are NULL. */ static void arraycopy(const long long* src, std::size_t srcPos, @@ -190,7 +196,8 @@ namespace lang * @param length * The number of elements to copy from src to dest. * - * @throws NullPointerException if src or dest are NULL. + * @throws activemq::exceptions::IllegalStateException if src or + * dest are NULL. */ static void arraycopy(const float* src, std::size_t srcPos, @@ -214,7 +221,8 @@ namespace lang * @param length * The number of elements to copy from src to dest. * - * @throws NullPointerException if src or dest are NULL. + * @throws activemq::exceptions::IllegalStateException if src or + * dest are NULL. */ static void arraycopy(const double* src, std::size_t srcPos, @@ -238,7 +246,8 @@ namespace lang * @param length * The number of elements to copy from src to dest. * - * @throws NullPointerException if src or dest are NULL. + * @throws activemq::exceptions::IllegalStateException if src or + * dest are NULL. */ template static void arraycopy(const E* src, @@ -249,15 +258,15 @@ namespace lang { if (src == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Given Source Pointer was null."); } - if (src == NULL) + if (dest == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Given Source Pointer was null."); @@ -289,6 +298,8 @@ namespace lang * * @return a string with the value from the variables or "" * + * @throws activemq::exceptions::IllegalStateException if the + * named environment variable is not set. * @throws an Exception if an error occurs while reading the Env. */ static std::string getenv(const std::string& name); @@ -396,7 +407,7 @@ namespace lang * @return an empty string if the named property is not set, otherwise returns the value. * - * @throws IllegalArgumentException if key is an empty string. + * @throws std::invalid_argument if key is an empty string. */ static std::string getProperty(const std::string& key); @@ -416,7 +427,7 @@ namespace lang * @return the value of the named system property or the defaultValue if * the property isn't set.. * - * @throws IllegalArgumentException if key is an empty string. + * @throws std::invalid_argument if key is an empty string. */ static std::string getProperty(const std::string& key, const std::string& defaultValue); @@ -432,7 +443,7 @@ namespace lang * @return the previous value of the property named by key if there was * one, otherwise returns an empty string. * - * @throws IllegalArgumentException if key is an empty string. + * @throws std::invalid_argument if key is an empty string. */ static std::string setProperty(const std::string& key, const std::string& value); @@ -446,7 +457,7 @@ namespace lang * @return the previous value of the property named by key if there was * one, otherwise returns an empty string. * - * @throws IllegalArgumentException if key is an empty string. + * @throws std::invalid_argument if key is an empty string. */ static std::string clearProperty(const std::string& key); diff --git a/activemq-cpp/src/main/decaf/lang/Thread.cpp b/activemq-cpp/src/main/decaf/lang/Thread.cpp index ed3dc4cdf..cac65a84e 100644 --- a/activemq-cpp/src/main/decaf/lang/Thread.cpp +++ b/activemq-cpp/src/main/decaf/lang/Thread.cpp @@ -27,13 +27,13 @@ #include #include #include -#include -#include -#include #include #include #include +#include +#include +#include #include using namespace decaf; @@ -41,7 +41,6 @@ using namespace decaf::internal; using namespace decaf::internal::util; using namespace decaf::internal::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -193,7 +192,7 @@ void Thread::start() } else if (currentState > Thread::NEW) { - throw IllegalThreadStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Thread::start - Thread already started"); @@ -201,10 +200,8 @@ void Thread::start() Threading::start(this->properties->handle); } - DECAF_CATCH_RETHROW(IllegalThreadStateException) - DECAF_CATCH_RETHROW(RuntimeException) - DECAF_CATCH_EXCEPTION_CONVERT(NullPointerException, RuntimeException) - DECAF_CATCHALL_THROW(RuntimeException) + DECAF_CATCH_RETHROW(Exception) + DECAF_CATCHALL_THROW(Exception) } //////////////////////////////////////////////////////////////////////////////// @@ -230,11 +227,10 @@ void Thread::join(long long millisecs) { if (millisecs < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Thread::join( millisecs ) - Value given {%d} is less than 0", - millisecs); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Thread::join( millisecs ) - Value given {" + + std::to_string(millisecs) + "} is less than 0"); } Threading::join(this->properties->handle, millisecs, 0); @@ -245,18 +241,17 @@ void Thread::join(long long millisecs, int nanos) { if (millisecs < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Thread::join( millisecs, nanos ) - " - "Value given {%d} is less than 0", - millisecs); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Thread::join( millisecs, nanos ) - " + "Value given {" + + std::to_string(millisecs) + "} is less than 0"); } if (nanos < 0 || nanos > 999999) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Thread::join( millisecs, nanos ) - Nanoseconds must be in range " "[0...999999]"); } @@ -275,18 +270,17 @@ void Thread::sleep(long long millisecs, int nanos) { if (millisecs < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Thread::sleep( millisecs, nanos ) - " - "Value given {%d} is less than 0", - millisecs); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Thread::sleep( millisecs, nanos ) - " + "Value given {" + + std::to_string(millisecs) + "} is less than 0"); } if (nanos < 0 || nanos > 999999) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Thread::sleep( millisecs, nanos ) - Nanoseconds must be in range " "[0...999999]"); } @@ -323,11 +317,10 @@ void Thread::setPriority(int value) { if (value < Thread::MIN_PRIORITY || value > Thread::MAX_PRIORITY) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Thread::setPriority - Specified value {%d} is out of range", - value); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Thread::setPriority - Specified value {" + std::to_string(value) + + "} is out of range"); } Threading::setThreadPriority(this->properties->handle, value); diff --git a/activemq-cpp/src/main/decaf/lang/Thread.h b/activemq-cpp/src/main/decaf/lang/Thread.h index 463759687..5ba27fb73 100644 --- a/activemq-cpp/src/main/decaf/lang/Thread.h +++ b/activemq-cpp/src/main/decaf/lang/Thread.h @@ -19,11 +19,8 @@ #include #include -#include -#include -#include -#include #include +#include #include namespace decaf @@ -202,7 +199,7 @@ namespace lang * * The stack size option is platform independent and may have no effect * on the newly created thread on some systems. If the value given is - * invalid on the system a RuntimeException is thrown, the stack size + * invalid on the system a Exception is thrown, the stack size * can be invalid if it is outside the allowed range or doesn't match * the size of the system page size on some system. * @@ -223,9 +220,9 @@ namespace lang * creation, the run() method of either this object or the provided * Runnable object will be invoked in the context of this thread. * - * @throws IllegalThreadStateException if the thread has already been + * @throws std::logic_error if the thread has already been * started. - * @throws RuntimeException if the Thread cannot be created for some + * @throws Exception if the Thread cannot be created for some * reason. */ virtual void start(); @@ -233,7 +230,7 @@ namespace lang /** * Forces the Current Thread to wait until the thread exits. * - * @throws InterruptedException if any thread has interrupted the + * @throws std::runtime_error if any thread has interrupted the * current thread. The interrupted status of the current thread is * cleared when this exception is thrown. */ @@ -244,9 +241,9 @@ namespace lang * * @param millisecs the time in Milliseconds before the thread resumes * - * @throws IllegalArgumentException if the milliseconds parameter is + * @throws std::invalid_argument if the milliseconds parameter is * negative. - * @throws InterruptedException if any thread has interrupted the + * @throws std::runtime_error if any thread has interrupted the * current thread. The interrupted status of the current thread is * cleared when this exception is thrown. */ @@ -258,9 +255,9 @@ namespace lang * @param millisecs the time in Milliseconds before the thread resumes * @param nanos 0-999999 extra nanoseconds to sleep. * - * @throws IllegalArgumentException if the nanoseconds parameter is out + * @throws std::invalid_argument if the nanoseconds parameter is out * of range or the milliseconds paramter is negative. - * @throws InterruptedException if any thread has interrupted the + * @throws std::runtime_error if any thread has interrupted the * current thread. The interrupted status of the current thread is * cleared when this exception is thrown. */ @@ -308,7 +305,7 @@ namespace lang * * @param value the new priority value to assign to this Thread. * - * @throws IllegalArgumentException if the value is out of range. + * @throws std::invalid_argument if the value is out of range. */ void setPriority(int value); @@ -356,10 +353,10 @@ namespace lang * * When the thread is in one of its own join or sleep methods or blocked * by a call to a monitor or mutex wait call it will clear its - * interrupted flag and and an InterruptedException will be thrown. + * interrupted flag and and an std::runtime_error will be thrown. * * In other cases the thread's interrupted status will be set and an - * instance of an InterruptedException may be thrown. + * instance of an std::runtime_error may be thrown. * * If the thread is not alive when this method is called there is no * affect. @@ -385,9 +382,9 @@ namespace lang * * @param millisecs time in milliseconds to halt execution. * - * @throws IllegalArgumentException if the milliseconds parameter is + * @throws std::invalid_argument if the milliseconds parameter is * negative. - * @throws InterruptedException if the Thread was interrupted while + * @throws std::runtime_error if the Thread was interrupted while * sleeping. */ static void sleep(long long millisecs); @@ -404,9 +401,9 @@ namespace lang * @param millisecs time in milliseconds to halt execution. * @param nanos 0-999999 extra nanoseconds to sleep. * - * @throws IllegalArgumentException if the nanoseconds parameter is out + * @throws std::invalid_argument if the nanoseconds parameter is out * of range or the milliseconds paramter is negative. - * @throws InterruptedException if the Thread was interrupted while + * @throws std::runtime_error if the Thread was interrupted while * sleeping. */ static void sleep(long long millisecs, int nanos); diff --git a/activemq-cpp/src/main/decaf/lang/Throwable.cpp b/activemq-cpp/src/main/decaf/lang/Throwable.cpp deleted file mode 100644 index c4a78edb0..000000000 --- a/activemq-cpp/src/main/decaf/lang/Throwable.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Throwable.h" - -using namespace decaf; -using namespace decaf::lang; - -//////////////////////////////////////////////////////////////////////////////// -Throwable::Throwable() - : std::exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -Throwable::~Throwable() throw() -{ -} diff --git a/activemq-cpp/src/main/decaf/lang/Throwable.h b/activemq-cpp/src/main/decaf/lang/Throwable.h index f0b960fe1..b05badfc7 100644 --- a/activemq-cpp/src/main/decaf/lang/Throwable.h +++ b/activemq-cpp/src/main/decaf/lang/Throwable.h @@ -118,6 +118,15 @@ namespace lang virtual std::string getStackTraceString() const = 0; }; + inline Throwable::Throwable() + : std::exception() + { + } + + inline Throwable::~Throwable() throw() + { + } + } // namespace lang } // namespace decaf diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/ArrayIndexOutOfBoundsException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/ArrayIndexOutOfBoundsException.cpp deleted file mode 100644 index 847a84ac5..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/ArrayIndexOutOfBoundsException.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ArrayIndexOutOfBoundsException.h" - -#include - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -ArrayIndexOutOfBoundsException::ArrayIndexOutOfBoundsException() - : IndexOutOfBoundsException() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ArrayIndexOutOfBoundsException::ArrayIndexOutOfBoundsException(int index) - : IndexOutOfBoundsException() -{ - this->setMessage("Array index out of range: %d", index); -} - -//////////////////////////////////////////////////////////////////////////////// -ArrayIndexOutOfBoundsException::~ArrayIndexOutOfBoundsException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ArrayIndexOutOfBoundsException::ArrayIndexOutOfBoundsException( - const Exception& ex) - : IndexOutOfBoundsException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -ArrayIndexOutOfBoundsException::ArrayIndexOutOfBoundsException( - const ArrayIndexOutOfBoundsException& ex) - : IndexOutOfBoundsException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -ArrayIndexOutOfBoundsException::ArrayIndexOutOfBoundsException( - const std::exception* cause) - : IndexOutOfBoundsException(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ArrayIndexOutOfBoundsException::ArrayIndexOutOfBoundsException( - const char* file, - const int lineNumber, - const char* msg, - ...) - : IndexOutOfBoundsException() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -ArrayIndexOutOfBoundsException::ArrayIndexOutOfBoundsException( - const char* file, - const int lineNumber, - int index) - : IndexOutOfBoundsException() -{ - setMark(file, lineNumber); - this->setMessage("Array index out of range: %d", index); -} - -//////////////////////////////////////////////////////////////////////////////// -ArrayIndexOutOfBoundsException::ArrayIndexOutOfBoundsException( - const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : IndexOutOfBoundsException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/ArrayIndexOutOfBoundsException.h b/activemq-cpp/src/main/decaf/lang/exceptions/ArrayIndexOutOfBoundsException.h deleted file mode 100644 index 281b0e971..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/ArrayIndexOutOfBoundsException.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_ARRAYINDEXOUTOFBOUNDSEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_ARRAYINDEXOUTOFBOUNDSEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an operation is requested, but the array index would - * result in an access that is outside the bounds of the array. - * - * @since 1.0 - */ - class DECAF_API ArrayIndexOutOfBoundsException - : public IndexOutOfBoundsException - { - public: - /** - * Default Constructor - */ - ArrayIndexOutOfBoundsException(); - - /** - * Create a new ArrayIndexOutOfBoundsException with the given index - * value to use to create the error message. - * - * @param index - * The given string index that was out of bounds. - */ - ArrayIndexOutOfBoundsException(int index); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - ArrayIndexOutOfBoundsException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - ArrayIndexOutOfBoundsException( - const ArrayIndexOutOfBoundsException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param cause - * The exception that was the cause for this one to be thrown. - * @param msg - * The message to report - * @param ... - * list of primitives that are formatted into the message - */ - ArrayIndexOutOfBoundsException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause - * Pointer to the exception that caused this one to be thrown, - * the object is cloned caller retains ownership. - */ - ArrayIndexOutOfBoundsException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param msg - * The message to report - * @param ... - * list of primitives that are formatted into the message - */ - ArrayIndexOutOfBoundsException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using the - * given index. - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param index - * The string index that was out of bounds. - */ - ArrayIndexOutOfBoundsException(const char* file, - const int lineNumber, - int index); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual ArrayIndexOutOfBoundsException* clone() const - { - return new ArrayIndexOutOfBoundsException(*this); - } - - virtual ~ArrayIndexOutOfBoundsException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_ARRAYINDEXOUTOFBOUNDSEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/ClassCastException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/ClassCastException.cpp deleted file mode 100644 index b326df9e7..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/ClassCastException.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ClassCastException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -ClassCastException::ClassCastException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ClassCastException::~ClassCastException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ClassCastException::ClassCastException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -ClassCastException::ClassCastException(const ClassCastException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -ClassCastException::ClassCastException(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ClassCastException::ClassCastException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -ClassCastException::ClassCastException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/ClassCastException.h b/activemq-cpp/src/main/decaf/lang/exceptions/ClassCastException.h deleted file mode 100644 index d44ac549a..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/ClassCastException.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_CLASSCASTEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_CLASSCASTEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an Dynamic Cast fails to convert a Pointer to a specified - * type. - * - * @since 1.0 - */ - class DECAF_API ClassCastException : public Exception - { - public: - /** - * Default Constructor - */ - ClassCastException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - ClassCastException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - ClassCastException(const ClassCastException& ex); - - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - ClassCastException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - ClassCastException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - ClassCastException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual ClassCastException* clone() const - { - return new ClassCastException(*this); - } - - virtual ~ClassCastException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_CLASSCASTEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/CloneNotSupportedException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/CloneNotSupportedException.cpp deleted file mode 100644 index 4f0e5d052..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/CloneNotSupportedException.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "CloneNotSupportedException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -CloneNotSupportedException::CloneNotSupportedException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -CloneNotSupportedException::~CloneNotSupportedException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -CloneNotSupportedException::CloneNotSupportedException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -CloneNotSupportedException::CloneNotSupportedException( - const CloneNotSupportedException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -CloneNotSupportedException::CloneNotSupportedException( - const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -CloneNotSupportedException::CloneNotSupportedException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -CloneNotSupportedException::CloneNotSupportedException( - const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/CloneNotSupportedException.h b/activemq-cpp/src/main/decaf/lang/exceptions/CloneNotSupportedException.h deleted file mode 100644 index bb2d14094..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/CloneNotSupportedException.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_CLONENOTSUPPORTEDEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_CLONENOTSUPPORTEDEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when a subclass of some class that defines a clone method does - * not support object cloning. - * - * @since 1.0 - */ - class DECAF_API CloneNotSupportedException : public Exception - { - public: - /** - * Default Constructor - */ - CloneNotSupportedException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - CloneNotSupportedException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - CloneNotSupportedException(const CloneNotSupportedException& ex); - - /** - * Constructor - * - * @param cause - * Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - CloneNotSupportedException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param msg - * The message to report - * @param ... - * list of primitives that are formatted into the message - */ - CloneNotSupportedException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param cause - * The exception that was the cause for this one to be thrown. - * @param msg - * The message to report - * @param ... - * list of primitives that are formatted into the message - */ - CloneNotSupportedException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual CloneNotSupportedException* clone() const - { - return new CloneNotSupportedException(*this); - } - - virtual ~CloneNotSupportedException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_CLASSCASTEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/ExceptionDefines.h b/activemq-cpp/src/main/decaf/lang/exceptions/ExceptionDefines.h index 4ce5e5ce6..52f05feed 100644 --- a/activemq-cpp/src/main/decaf/lang/exceptions/ExceptionDefines.h +++ b/activemq-cpp/src/main/decaf/lang/exceptions/ExceptionDefines.h @@ -18,6 +18,9 @@ #ifndef _DECAF_LANG_EXCEPTIONS_EXCEPTIONDEFINES_H_ #define _DECAF_LANG_EXCEPTIONS_EXCEPTIONDEFINES_H_ +#include +#include + /** * Macro for catching and rethrowing an exception of * a given type. @@ -47,21 +50,45 @@ /** * A catch-all that throws a known exception. - * @param type the type of exception to be thrown. + * + * AMQ thin STL-backed exceptions (see StdExceptionCatchMacros.h) are + * rethrown unchanged before \p type is thrown for unknown failures. + * + * @param type the type of exception to be thrown for failures outside the + * standard logic_error / runtime_error hierarchies. */ #define DECAF_CATCHALL_THROW(type) \ + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() \ catch (...) \ { \ type ex(__FILE__, __LINE__, "caught unknown exception"); \ throw ex; \ } +/** + * Like DECAF_CATCHALL_THROW but skips OutOfRangeException in the AMQ rethrow + * list (use after a catch that maps or rethrows OutOfRangeException so it is + * not shadowed). + */ +#define DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP(type) \ + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS_AFTER_OUT_OF_RANGE_MAP() \ + catch (...) \ + { \ + type ex(__FILE__, __LINE__, "caught unknown exception"); \ + throw ex; \ + } + /** * A catch-all that does not throw an exception, one use would * be to catch any exception in a destructor and mark it, but not * throw so that cleanup would continue as normal. + * + * AMQ thin STL-backed exceptions are swallowed explicitly first so behavior + * matches a single catch (...) that would otherwise absorb them; non-standard + * exceptions still construct a marked Exception for diagnostics. */ #define DECAF_CATCHALL_NOTHROW() \ + AMQ_CATCHALL_SWALLOW_STL_BACKED_EXCEPTIONS() \ catch (...) \ { \ lang::Exception ex(__FILE__, \ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalArgumentException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/IllegalArgumentException.cpp deleted file mode 100644 index 1b778746e..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalArgumentException.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "IllegalArgumentException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -IllegalArgumentException::IllegalArgumentException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalArgumentException::~IllegalArgumentException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalArgumentException::IllegalArgumentException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalArgumentException::IllegalArgumentException( - const IllegalArgumentException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalArgumentException::IllegalArgumentException(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalArgumentException::IllegalArgumentException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalArgumentException::IllegalArgumentException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalArgumentException.h b/activemq-cpp/src/main/decaf/lang/exceptions/IllegalArgumentException.h deleted file mode 100644 index 2c475bb03..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalArgumentException.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_ILLEGALARGUMENTEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_ILLEGALARGUMENTEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an illegal argument was passed into a method. - * - * @since 1.0 - */ - class DECAF_API IllegalArgumentException : public Exception - { - public: - /** - * Default Constructor - */ - IllegalArgumentException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - IllegalArgumentException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - IllegalArgumentException(const IllegalArgumentException& ex); - - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - IllegalArgumentException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - IllegalArgumentException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - IllegalArgumentException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual IllegalArgumentException* clone() const - { - return new IllegalArgumentException(*this); - } - - virtual ~IllegalArgumentException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_ILLEGALARGUMENTEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalMonitorStateException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/IllegalMonitorStateException.cpp deleted file mode 100644 index b39a44f1d..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalMonitorStateException.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "IllegalMonitorStateException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -IllegalMonitorStateException::IllegalMonitorStateException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalMonitorStateException::~IllegalMonitorStateException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalMonitorStateException::IllegalMonitorStateException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalMonitorStateException::IllegalMonitorStateException( - const IllegalMonitorStateException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalMonitorStateException::IllegalMonitorStateException( - const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalMonitorStateException::IllegalMonitorStateException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalMonitorStateException::IllegalMonitorStateException( - const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalMonitorStateException.h b/activemq-cpp/src/main/decaf/lang/exceptions/IllegalMonitorStateException.h deleted file mode 100644 index 68407907d..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalMonitorStateException.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_ILLEGALMONITORSTATEEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_ILLEGALMONITORSTATEEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an error occurs from calling a method from syncronizable - * and the caller doesn't hold a lock on the object. - * - * @since 1.0 - */ - class DECAF_API IllegalMonitorStateException : public Exception - { - public: - /** - * Default Constructor - */ - IllegalMonitorStateException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - IllegalMonitorStateException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - IllegalMonitorStateException(const IllegalMonitorStateException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - IllegalMonitorStateException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - IllegalMonitorStateException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - IllegalMonitorStateException(const std::exception* cause); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual IllegalMonitorStateException* clone() const - { - return new IllegalMonitorStateException(*this); - } - - virtual ~IllegalMonitorStateException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_ILLEGALMONITORSTATEEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalStateException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/IllegalStateException.cpp deleted file mode 100644 index 3292b181e..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalStateException.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "IllegalStateException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -IllegalStateException::IllegalStateException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalStateException::~IllegalStateException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalStateException::IllegalStateException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalStateException::IllegalStateException(const IllegalStateException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalStateException::IllegalStateException(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalStateException::IllegalStateException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalStateException::IllegalStateException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalStateException.h b/activemq-cpp/src/main/decaf/lang/exceptions/IllegalStateException.h deleted file mode 100644 index 1cfd4c734..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalStateException.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_ILLEGALSTATEEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_ILLEGALSTATEEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an error occurs from calling a method from syncronizable - * and the caller doesn't hold a lock on the object. - * - * @since 1.0 - */ - class DECAF_API IllegalStateException : public Exception - { - public: - /** - * Default Constructor - */ - IllegalStateException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - IllegalStateException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - IllegalStateException(const IllegalStateException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - IllegalStateException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - IllegalStateException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - IllegalStateException(const std::exception* cause); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual IllegalStateException* clone() const - { - return new IllegalStateException(*this); - } - - virtual ~IllegalStateException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_ILLEGALSTATEEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalThreadStateException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/IllegalThreadStateException.cpp deleted file mode 100644 index 06e19e1b8..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalThreadStateException.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "IllegalThreadStateException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -IllegalThreadStateException::IllegalThreadStateException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalThreadStateException::~IllegalThreadStateException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalThreadStateException::IllegalThreadStateException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalThreadStateException::IllegalThreadStateException( - const IllegalThreadStateException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalThreadStateException::IllegalThreadStateException( - const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalThreadStateException::IllegalThreadStateException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -IllegalThreadStateException::IllegalThreadStateException( - const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalThreadStateException.h b/activemq-cpp/src/main/decaf/lang/exceptions/IllegalThreadStateException.h deleted file mode 100644 index e21cbf529..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/IllegalThreadStateException.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_ILLEGALTHREADSTATEEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_ILLEGALTHREADSTATEEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an error occurs when a user tries to start a Thread that - * has already been started. - * - * @since 1.0 - */ - class DECAF_API IllegalThreadStateException : public Exception - { - public: - /** - * Default Constructor - */ - IllegalThreadStateException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - IllegalThreadStateException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - IllegalThreadStateException(const IllegalThreadStateException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occured. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - IllegalThreadStateException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - IllegalThreadStateException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - IllegalThreadStateException(const std::exception* cause); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual IllegalThreadStateException* clone() const - { - return new IllegalThreadStateException(*this); - } - - virtual ~IllegalThreadStateException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_ILLEGALTHREADSTATEEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/IndexOutOfBoundsException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/IndexOutOfBoundsException.cpp deleted file mode 100644 index d0e551d7b..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/IndexOutOfBoundsException.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "IndexOutOfBoundsException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -IndexOutOfBoundsException::IndexOutOfBoundsException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IndexOutOfBoundsException::~IndexOutOfBoundsException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IndexOutOfBoundsException::IndexOutOfBoundsException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IndexOutOfBoundsException::IndexOutOfBoundsException( - const IndexOutOfBoundsException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -IndexOutOfBoundsException::IndexOutOfBoundsException(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -IndexOutOfBoundsException::IndexOutOfBoundsException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -IndexOutOfBoundsException::IndexOutOfBoundsException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/IndexOutOfBoundsException.h b/activemq-cpp/src/main/decaf/lang/exceptions/IndexOutOfBoundsException.h deleted file mode 100644 index 6e24fe4c8..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/IndexOutOfBoundsException.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_INDEXOUTOFBOUNDSEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_INDEXOUTOFBOUNDSEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an illegal argument was passed into a method. - * - * @since 1.0 - */ - class DECAF_API IndexOutOfBoundsException : public Exception - { - public: - /** - * Default Constructor - */ - IndexOutOfBoundsException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - IndexOutOfBoundsException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - IndexOutOfBoundsException(const IndexOutOfBoundsException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - IndexOutOfBoundsException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - IndexOutOfBoundsException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - IndexOutOfBoundsException(const std::exception* cause); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual IndexOutOfBoundsException* clone() const - { - return new IndexOutOfBoundsException(*this); - } - - virtual ~IndexOutOfBoundsException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_INDEXOUTOFBOUNDSEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/InterruptedException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/InterruptedException.cpp deleted file mode 100644 index 159993718..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/InterruptedException.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "InterruptedException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -InterruptedException::InterruptedException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedException::~InterruptedException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedException::InterruptedException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedException::InterruptedException(const InterruptedException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedException::InterruptedException(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedException::InterruptedException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -InterruptedException::InterruptedException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/InterruptedException.h b/activemq-cpp/src/main/decaf/lang/exceptions/InterruptedException.h deleted file mode 100644 index 92a81b470..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/InterruptedException.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_INTERRUPTEDENTEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_INTERRUPTEDENTEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an Thread is interrupted during a wait. - * - * @since 1.0 - */ - class DECAF_API InterruptedException : public Exception - { - public: - /** - * Default Constructor - */ - InterruptedException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - InterruptedException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - InterruptedException(const InterruptedException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - InterruptedException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - InterruptedException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - InterruptedException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual InterruptedException* clone() const - { - return new InterruptedException(*this); - } - - virtual ~InterruptedException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_INTERRUPTEDENTEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/InvalidStateException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/InvalidStateException.cpp deleted file mode 100644 index f40fd483f..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/InvalidStateException.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "InvalidStateException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -InvalidStateException::InvalidStateException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -InvalidStateException::~InvalidStateException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -InvalidStateException::InvalidStateException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -InvalidStateException::InvalidStateException(const InvalidStateException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -InvalidStateException::InvalidStateException(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -InvalidStateException::InvalidStateException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -InvalidStateException::InvalidStateException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/InvalidStateException.h b/activemq-cpp/src/main/decaf/lang/exceptions/InvalidStateException.h deleted file mode 100644 index bdd6bd373..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/InvalidStateException.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_INVALIDSTATEEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_INVALIDSTATEEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an operation is requested, but the state of the object - * servicing the request is not correct for that request. - * - * @since 1.0 - */ - class DECAF_API InvalidStateException : public Exception - { - public: - /** - * Default Constructor - */ - InvalidStateException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - InvalidStateException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - InvalidStateException(const InvalidStateException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param cause - * The exception that was the cause for this one to be thrown. - * @param msg - * The message to report - * @param ... - * list of primitives that are formatted into the message - */ - InvalidStateException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause - * Pointer to the exception that caused this one to be thrown, - * the object is cloned caller retains ownership. - */ - InvalidStateException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param msg - * The message to report - * @param ... - * list of primitives that are formatted into the message - */ - InvalidStateException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual InvalidStateException* clone() const - { - return new InvalidStateException(*this); - } - - virtual ~InvalidStateException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_INVALIDSTATEEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/NegativeArraySizeException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/NegativeArraySizeException.cpp deleted file mode 100644 index 27cf41718..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/NegativeArraySizeException.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "NegativeArraySizeException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -NegativeArraySizeException::NegativeArraySizeException() - : RuntimeException() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NegativeArraySizeException::~NegativeArraySizeException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NegativeArraySizeException::NegativeArraySizeException(const Exception& ex) - : RuntimeException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -NegativeArraySizeException::NegativeArraySizeException( - const NegativeArraySizeException& ex) - : RuntimeException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -NegativeArraySizeException::NegativeArraySizeException( - const std::exception* cause) - : RuntimeException(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NegativeArraySizeException::NegativeArraySizeException(const char* file, - const int lineNumber, - const char* msg, - ...) - : RuntimeException() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -NegativeArraySizeException::NegativeArraySizeException( - const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : RuntimeException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/NegativeArraySizeException.h b/activemq-cpp/src/main/decaf/lang/exceptions/NegativeArraySizeException.h deleted file mode 100644 index 4775e5e1b..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/NegativeArraySizeException.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_NEGATIVEARRAYSIZEEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_NEGATIVEARRAYSIZEEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown if an application tries to create an array with negative size. - * - * @since 1.0 - */ - class DECAF_API NegativeArraySizeException : public RuntimeException - { - public: - /** - * Default Constructor - */ - NegativeArraySizeException(); - - /** - * Conversion Constructor from some other Decaf Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - NegativeArraySizeException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - NegativeArraySizeException(const NegativeArraySizeException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - NegativeArraySizeException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - NegativeArraySizeException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - NegativeArraySizeException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception that is a copy of this one. - */ - virtual NegativeArraySizeException* clone() const - { - return new NegativeArraySizeException(*this); - } - - virtual ~NegativeArraySizeException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_NEGATIVEARRAYSIZEEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/NullPointerException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/NullPointerException.cpp deleted file mode 100644 index 25a0aba6f..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/NullPointerException.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "NullPointerException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -NullPointerException::NullPointerException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NullPointerException::~NullPointerException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NullPointerException::NullPointerException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -NullPointerException::NullPointerException(const NullPointerException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -NullPointerException::NullPointerException(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NullPointerException::NullPointerException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -NullPointerException::NullPointerException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/NullPointerException.h b/activemq-cpp/src/main/decaf/lang/exceptions/NullPointerException.h deleted file mode 100644 index 41d52cb24..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/NullPointerException.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DECAF_LANG_EXCEPTIONS_NULLPOINTERENTEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_NULLPOINTERENTEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an error occurs that involves a pointer being NULL - * - * @since 1.0 - */ - class DECAF_API NullPointerException : public Exception - { - public: - /** - * Default Constructor - */ - NullPointerException(); - - /** - * Conversion Constructor from some other Exception. - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - NullPointerException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - NullPointerException(const NullPointerException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - NullPointerException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - NullPointerException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occured. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - NullPointerException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual NullPointerException* clone() const - { - return new NullPointerException(*this); - } - - virtual ~NullPointerException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_NULLPOINTERENTEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/NumberFormatException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/NumberFormatException.cpp deleted file mode 100644 index f9a154af8..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/NumberFormatException.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "NumberFormatException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -NumberFormatException::NumberFormatException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NumberFormatException::~NumberFormatException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NumberFormatException::NumberFormatException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -NumberFormatException::NumberFormatException(const NumberFormatException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -NumberFormatException::NumberFormatException(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NumberFormatException::NumberFormatException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -NumberFormatException::NumberFormatException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/NumberFormatException.h b/activemq-cpp/src/main/decaf/lang/exceptions/NumberFormatException.h deleted file mode 100644 index 384ee0ab6..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/NumberFormatException.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DECAF_LANG_EXCEPTIONS_NUMBERFORMATEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_NUMBERFORMATEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an error occurs that involves a conversion to a Number - * from a string and the string is not a valid number. - * - * @since 1.0 - */ - class NumberFormatException : public Exception - { - public: - /** - * Default Constructor - */ - NumberFormatException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - NumberFormatException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - NumberFormatException(const NumberFormatException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - NumberFormatException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - NumberFormatException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occured. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - NumberFormatException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual NumberFormatException* clone() const - { - return new NumberFormatException(*this); - } - - virtual ~NumberFormatException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_NUMBERFORMATEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/OutOfMemoryError.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/OutOfMemoryError.cpp deleted file mode 100644 index eaba108f1..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/OutOfMemoryError.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "OutOfMemoryError.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -OutOfMemoryError::OutOfMemoryError() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -OutOfMemoryError::~OutOfMemoryError() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -OutOfMemoryError::OutOfMemoryError(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -OutOfMemoryError::OutOfMemoryError(const OutOfMemoryError& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -OutOfMemoryError::OutOfMemoryError(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -OutOfMemoryError::OutOfMemoryError(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -OutOfMemoryError::OutOfMemoryError(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/OutOfMemoryError.h b/activemq-cpp/src/main/decaf/lang/exceptions/OutOfMemoryError.h deleted file mode 100755 index 1c524b568..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/OutOfMemoryError.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_OUTOFMEMORYERROR_H_ -#define _DECAF_LANG_EXCEPTIONS_OUTOFMEMORYERROR_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an allocation operation fails indicating not enough - * memory. - * - * @since 1.0 - */ - class DECAF_API OutOfMemoryError : public Exception - { - public: - /** - * Default Constructor - */ - OutOfMemoryError(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - OutOfMemoryError(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - OutOfMemoryError(const OutOfMemoryError& ex); - - /** - * Constructor - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - OutOfMemoryError(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - OutOfMemoryError(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - OutOfMemoryError(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual OutOfMemoryError* clone() const - { - return new OutOfMemoryError(*this); - } - - virtual ~OutOfMemoryError() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_OUTOFMEMORYERROR_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/RuntimeException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/RuntimeException.cpp deleted file mode 100644 index 69485ab63..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/RuntimeException.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "RuntimeException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -RuntimeException::RuntimeException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -RuntimeException::~RuntimeException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -RuntimeException::RuntimeException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -RuntimeException::RuntimeException(const RuntimeException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -RuntimeException::RuntimeException(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -RuntimeException::RuntimeException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -RuntimeException::RuntimeException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/RuntimeException.h b/activemq-cpp/src/main/decaf/lang/exceptions/RuntimeException.h deleted file mode 100644 index 65f5630a3..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/RuntimeException.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_RUNTIMEENTEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_RUNTIMEENTEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an error occurs that involves something in the run time - * This could be a memory allocation exception or some other generally - * unrecoverable exception. - * - * @since 1.0 - */ - class DECAF_API RuntimeException : public Exception - { - public: - /** - * Default Constructor - */ - RuntimeException(); - - /** - * Conversion Constructor from some other ActiveMQException - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - RuntimeException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - RuntimeException(const RuntimeException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - RuntimeException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - RuntimeException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - RuntimeException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception that is a copy of this one. - */ - virtual RuntimeException* clone() const - { - return new RuntimeException(*this); - } - - virtual ~RuntimeException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_RUNTIMEENTEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/SecurityException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/SecurityException.cpp deleted file mode 100644 index 385ddde81..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/SecurityException.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "SecurityException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -SecurityException::SecurityException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -SecurityException::~SecurityException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -SecurityException::SecurityException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -SecurityException::SecurityException(const SecurityException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -SecurityException::SecurityException(const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -SecurityException::SecurityException(const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -SecurityException::SecurityException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/SecurityException.h b/activemq-cpp/src/main/decaf/lang/exceptions/SecurityException.h deleted file mode 100644 index ccef728d9..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/SecurityException.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_SECURITYEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_SECURITYEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an operation is requested, but the state of the object - * servicing the request is not correct for that request. - * - * @since 1.0 - */ - class DECAF_API SecurityException : public Exception - { - public: - /** - * Default Constructor - */ - SecurityException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - SecurityException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - SecurityException(const SecurityException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param cause - * The exception that was the cause for this one to be thrown. - * @param msg - * The message to report - * @param ... - * list of primitives that are formatted into the message - */ - SecurityException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause - * Pointer to the exception that caused this one to be thrown, - * the object is cloned caller retains ownership. - */ - SecurityException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param msg - * The message to report - * @param ... - * list of primitives that are formatted into the message - */ - SecurityException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual SecurityException* clone() const - { - return new SecurityException(*this); - } - - virtual ~SecurityException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_SECURITYEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/StringIndexOutOfBoundsException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/StringIndexOutOfBoundsException.cpp deleted file mode 100644 index 152d315c5..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/StringIndexOutOfBoundsException.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "StringIndexOutOfBoundsException.h" - -#include - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -StringIndexOutOfBoundsException::StringIndexOutOfBoundsException() - : IndexOutOfBoundsException() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -StringIndexOutOfBoundsException::StringIndexOutOfBoundsException(int index) - : IndexOutOfBoundsException() -{ - this->setMessage("String index out of range: %d", index); -} - -//////////////////////////////////////////////////////////////////////////////// -StringIndexOutOfBoundsException::~StringIndexOutOfBoundsException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -StringIndexOutOfBoundsException::StringIndexOutOfBoundsException( - const Exception& ex) - : IndexOutOfBoundsException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -StringIndexOutOfBoundsException::StringIndexOutOfBoundsException( - const StringIndexOutOfBoundsException& ex) - : IndexOutOfBoundsException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -StringIndexOutOfBoundsException::StringIndexOutOfBoundsException( - const std::exception* cause) - : IndexOutOfBoundsException(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -StringIndexOutOfBoundsException::StringIndexOutOfBoundsException( - const char* file, - const int lineNumber, - const char* msg, - ...) - : IndexOutOfBoundsException() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -StringIndexOutOfBoundsException::StringIndexOutOfBoundsException( - const char* file, - const int lineNumber, - int index) - : IndexOutOfBoundsException() -{ - setMark(file, lineNumber); - this->setMessage("String index out of range: %d", index); -} - -//////////////////////////////////////////////////////////////////////////////// -StringIndexOutOfBoundsException::StringIndexOutOfBoundsException( - const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : IndexOutOfBoundsException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/StringIndexOutOfBoundsException.h b/activemq-cpp/src/main/decaf/lang/exceptions/StringIndexOutOfBoundsException.h deleted file mode 100644 index bc4fe399c..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/StringIndexOutOfBoundsException.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_STRINGINDEXOUTOFBOUNDSEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_STRINGINDEXOUTOFBOUNDSEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an operation is requested, but the state of the object - * servicing the request is not correct for that request. - * - * @since 1.0 - */ - class DECAF_API StringIndexOutOfBoundsException - : public IndexOutOfBoundsException - { - public: - /** - * Default Constructor - */ - StringIndexOutOfBoundsException(); - - /** - * Create a new StringIndexOutOfBoundsException with the given index - * value to use to create the error message. - * - * @param index - * The given string index that was out of bounds. - */ - StringIndexOutOfBoundsException(int index); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - StringIndexOutOfBoundsException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - StringIndexOutOfBoundsException( - const StringIndexOutOfBoundsException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param cause - * The exception that was the cause for this one to be thrown. - * @param msg - * The message to report - * @param ... - * list of primitives that are formatted into the message - */ - StringIndexOutOfBoundsException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause - * Pointer to the exception that caused this one to be thrown, - * the object is cloned caller retains ownership. - */ - StringIndexOutOfBoundsException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param msg - * The message to report - * @param ... - * list of primitives that are formatted into the message - */ - StringIndexOutOfBoundsException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using the - * given index. - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param index - * The string index that was out of bounds. - */ - StringIndexOutOfBoundsException(const char* file, - const int lineNumber, - int index); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual StringIndexOutOfBoundsException* clone() const - { - return new StringIndexOutOfBoundsException(*this); - } - - virtual ~StringIndexOutOfBoundsException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_STRINGINDEXOUTOFBOUNDSEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/UnsupportedOperationException.cpp b/activemq-cpp/src/main/decaf/lang/exceptions/UnsupportedOperationException.cpp deleted file mode 100644 index 1bb4049af..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/UnsupportedOperationException.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "UnsupportedOperationException.h" - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedOperationException::UnsupportedOperationException() - : Exception() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedOperationException::~UnsupportedOperationException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedOperationException::UnsupportedOperationException(const Exception& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedOperationException::UnsupportedOperationException( - const UnsupportedOperationException& ex) - : Exception() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedOperationException::UnsupportedOperationException( - const std::exception* cause) - : Exception(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedOperationException::UnsupportedOperationException( - const char* file, - const int lineNumber, - const char* msg, - ...) - : Exception() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -UnsupportedOperationException::UnsupportedOperationException( - const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : Exception(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/lang/exceptions/UnsupportedOperationException.h b/activemq-cpp/src/main/decaf/lang/exceptions/UnsupportedOperationException.h deleted file mode 100644 index b42ce346b..000000000 --- a/activemq-cpp/src/main/decaf/lang/exceptions/UnsupportedOperationException.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_LANG_EXCEPTIONS_UNSUPPORTEDOPERATIONEXCEPTION_H_ -#define _DECAF_LANG_EXCEPTIONS_UNSUPPORTEDOPERATIONEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace lang -{ - namespace exceptions - { - - /* - * Thrown when an unsupported method is called or an operation cannot be - * performed because it was not implemented. - * - * @since 1.0 - */ - class DECAF_API UnsupportedOperationException : public lang::Exception - { - public: - /** - * Default Constructor - */ - UnsupportedOperationException(); - - /** - * Conversion Constructor from some other Exception - * @param ex An exception that should become this type of Exception - */ - UnsupportedOperationException(const Exception& ex); - - /** - * Copy Constructor - * @param ex An exception that should become this type of Exception - */ - UnsupportedOperationException( - const UnsupportedOperationException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - UnsupportedOperationException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - UnsupportedOperationException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - UnsupportedOperationException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual UnsupportedOperationException* clone() const - { - return new UnsupportedOperationException(*this); - } - - virtual ~UnsupportedOperationException() throw(); - }; - - } // namespace exceptions -} // namespace lang -} // namespace decaf - -#endif /*_DECAF_LANG_EXCEPTIONS_UNSUPPORTEDOPERATIONEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/net/DatagramPacket.cpp b/activemq-cpp/src/main/decaf/net/DatagramPacket.cpp index 896fa4644..3c1b59087 100644 --- a/activemq-cpp/src/main/decaf/net/DatagramPacket.cpp +++ b/activemq-cpp/src/main/decaf/net/DatagramPacket.cpp @@ -16,11 +16,13 @@ */ #include "DatagramPacket.h" +#include +#include +#include using namespace decaf; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util::concurrent; //////////////////////////////////////////////////////////////////////////////// @@ -183,10 +185,9 @@ void DatagramPacket::setPort(int port) { if (port < 0 || port > 65535) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Given port value is out of range, %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Given port value is out of range, " + std::to_string(port)); } synchronized(&mutex) @@ -214,10 +215,9 @@ void DatagramPacket::setOffset(int offset) { if (offset < 0 || offset > size) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Offset value is invalid: %d", - offset); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset value is invalid: " + std::to_string(offset)); } this->offset = offset; @@ -243,10 +243,9 @@ void DatagramPacket::setLength(int length) { if (length < 0 || (size - offset) > length) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Length value is invalid: %d", - length); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Length value is invalid: " + std::to_string(length)); } this->length = length; @@ -282,17 +281,17 @@ void DatagramPacket::setData(unsigned char* buffer, int size) { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Provided Buffer pointer was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Provided Buffer pointer was NULL."); } if (size <= 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Size value is invalid: %d", - size); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Size value is invalid: " + std::to_string(size)); } synchronized(&mutex) @@ -312,33 +311,31 @@ void DatagramPacket::setData(unsigned char* buffer, { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Provided Buffer pointer was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Provided Buffer pointer was NULL."); } if (size <= 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Size value is invalid: %d", - size); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Size value is invalid: " + std::to_string(size)); } if (offset < 0 || offset > size) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Offset value is invalid: %d", - offset); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Offset value is invalid: " + std::to_string(offset)); } if (length < 0 || (size - offset) > length) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Length value is invalid: %d", - length); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Length value is invalid: " + std::to_string(length)); } synchronized(&mutex) diff --git a/activemq-cpp/src/main/decaf/net/DatagramPacket.h b/activemq-cpp/src/main/decaf/net/DatagramPacket.h index 75721e610..3d672801c 100644 --- a/activemq-cpp/src/main/decaf/net/DatagramPacket.h +++ b/activemq-cpp/src/main/decaf/net/DatagramPacket.h @@ -23,11 +23,8 @@ #include #include -#include -#include -#include - #include +#include namespace decaf { @@ -72,8 +69,8 @@ namespace net * @param length * The number of byte to read starting at the supplied offset. * - * @throws NullPointerException if the pointer to the buffer is NULL. - * @throws IndexOutOfBoundsException if the number of bytes to read + * @throws std::logic_error if the pointer to the buffer is NULL. + * @throws std::out_of_range if the number of bytes to read * exceeds the buffer size. */ DatagramPacket(unsigned char* bytes, int size, int length); @@ -91,8 +88,8 @@ namespace net * @param length * The number of byte to read starting at the supplied offset. * - * @throws NullPointerException if the pointer to the buffer is NULL. - * @throws IndexOutOfBoundsException if the number of bytes to copy + * @throws std::logic_error if the pointer to the buffer is NULL. + * @throws std::out_of_range if the number of bytes to copy * exceeds the buffer size. */ DatagramPacket(unsigned char* bytes, int size, int offset, int length); @@ -115,8 +112,8 @@ namespace net * @param port * The port on the destination that is to receive this packet. * - * @throws NullPointerException if the pointer to the buffer is NULL. - * @throws IndexOutOfBoundsException if the number of bytes to copy + * @throws std::logic_error if the pointer to the buffer is NULL. + * @throws std::out_of_range if the number of bytes to copy * exceeds the buffer size. */ DatagramPacket(unsigned char* bytes, @@ -141,8 +138,8 @@ namespace net * @param port * The port on the destination that is to receive this packet. * - * @throws NullPointerException if the pointer to the buffer is NULL. - * @throws IndexOutOfBoundsException if the number of bytes to copy + * @throws std::logic_error if the pointer to the buffer is NULL. + * @throws std::out_of_range if the number of bytes to copy * exceeds the buffer size. */ DatagramPacket(unsigned char* bytes, @@ -164,8 +161,8 @@ namespace net * @param address * The Address to send the packet to * - * @throws NullPointerException if the pointer to the buffer is NULL. - * @throws IndexOutOfBoundsException if the number of bytes to copy + * @throws std::logic_error if the pointer to the buffer is NULL. + * @throws std::out_of_range if the number of bytes to copy * exceeds the buffer size. */ DatagramPacket(unsigned char* bytes, @@ -189,8 +186,8 @@ namespace net * @param address * The Address to send the packet to * - * @throws NullPointerException if the pointer to the buffer is NULL. - * @throws IndexOutOfBoundsException if the number of bytes to copy + * @throws std::logic_error if the pointer to the buffer is NULL. + * @throws std::out_of_range if the number of bytes to copy * exceeds the buffer size. */ DatagramPacket(unsigned char* bytes, @@ -232,7 +229,7 @@ namespace net * @param address * The SocketAddress (IP + port) for this datagram packet. * - * @throws IllegalArgumentException if the subclass of address is not + * @throws std::invalid_argument if the subclass of address is not * supported by this Socket. */ void setSocketAddress(const SocketAddress& address); @@ -250,7 +247,7 @@ namespace net * @param port * The port on the remote host. * - * @throws IllegalArgumentException if the port value is not in the + * @throws std::invalid_argument if the port value is not in the * range [0..65535]. */ void setPort(int port); @@ -268,7 +265,7 @@ namespace net * @param offset * The buffer offset value. * - * @throws IllegalArgumentException if the offset value is greater than + * @throws std::invalid_argument if the offset value is greater than * the buffer size. */ void setOffset(int offset); @@ -289,7 +286,7 @@ namespace net * @param length * The length value to set for this packet. * - * @throws IllegalArgumentException if the value is negative or exceeds + * @throws std::invalid_argument if the value is negative or exceeds * the data buffers length. */ void setLength(int length); @@ -315,7 +312,7 @@ namespace net * @param size * The size of the buffer. * - * @throws NullPointerException if the buffer pointer is NULL. + * @throws std::logic_error if the buffer pointer is NULL. */ void setData(unsigned char* buffer, int size); @@ -334,7 +331,7 @@ namespace net * The number of bytes that will be read into the buffer or sent * from the buffer. * - * @throws NullPointerException if the buffer pointer is NULL. + * @throws std::logic_error if the buffer pointer is NULL. */ void setData(unsigned char* buffer, int size, int offset, int length); }; diff --git a/activemq-cpp/src/main/decaf/net/HttpURLConnection.cpp b/activemq-cpp/src/main/decaf/net/HttpURLConnection.cpp index d9f9c43d5..570f4e1ca 100644 --- a/activemq-cpp/src/main/decaf/net/HttpURLConnection.cpp +++ b/activemq-cpp/src/main/decaf/net/HttpURLConnection.cpp @@ -18,12 +18,14 @@ #include #include -#include #include +#include +#include +#include + using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::net; //////////////////////////////////////////////////////////////////////////////// @@ -156,21 +158,24 @@ void HttpURLConnection::setFixedLengthStreamingMode(int contentLength) { if (connected) { - throw IllegalStateException(__FILE__, __LINE__, "Already connected"); + throw activemq::exceptions::IllegalStateException(__FILE__, + __LINE__, + "Already connected"); } if (0 < chunkLength) { - throw IllegalStateException(__FILE__, - __LINE__, - "different mode already set"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "different mode already set"); } if (0 > contentLength) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "scale value < than zero"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "scale value < than zero"); } fixedContentLength = contentLength; @@ -181,14 +186,17 @@ void HttpURLConnection::setChunkedStreamingMode(int chunklen) { if (connected) { - throw IllegalStateException(__FILE__, __LINE__, "Already connected"); + throw activemq::exceptions::IllegalStateException(__FILE__, + __LINE__, + "Already connected"); } if (0 <= fixedContentLength) { - throw IllegalStateException(__FILE__, - __LINE__, - "different mode already set"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "different mode already set"); } if (0 >= chunklen) diff --git a/activemq-cpp/src/main/decaf/net/HttpURLConnection.h b/activemq-cpp/src/main/decaf/net/HttpURLConnection.h index 85a1bad7a..f8d2a3c16 100644 --- a/activemq-cpp/src/main/decaf/net/HttpURLConnection.h +++ b/activemq-cpp/src/main/decaf/net/HttpURLConnection.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace decaf { @@ -370,9 +371,9 @@ namespace net * @param contentLength * the fixed length of the HTTP request body. * - * @throws IllegalStateException if already connected or an other mode + * @throws std::logic_error if already connected or an other mode * already set. - * @throws IllegalArgumentException if contentLength is less than zero. + * @throws std::invalid_argument if contentLength is less than zero. */ void setFixedLengthStreamingMode(int contentLength); @@ -385,7 +386,7 @@ namespace net * @param chunklen * the length of a chunk. * - * @throws IllegalStateException if already connected or an other mode + * @throws std::logic_error if already connected or an other mode * already set. */ void setChunkedStreamingMode(int chunklen); diff --git a/activemq-cpp/src/main/decaf/net/InetAddress.cpp b/activemq-cpp/src/main/decaf/net/InetAddress.cpp index 6fbd8d402..52f6d9ca2 100644 --- a/activemq-cpp/src/main/decaf/net/InetAddress.cpp +++ b/activemq-cpp/src/main/decaf/net/InetAddress.cpp @@ -18,18 +18,20 @@ #include "InetAddress.h" #include +#include #include -#include #include #include #include +#include +#include +#include #include using namespace decaf; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; //////////////////////////////////////////////////////////////////////////////// @@ -52,18 +54,15 @@ InetAddress::InetAddress(const unsigned char* ipAddress, int numBytes) { if (ipAddress == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "InetAddress constructor called with null address array."); } if (numBytes < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Number of bytes value is invalid: %d", - numBytes); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Number of bytes value is invalid: " + std::to_string(numBytes)); } unsigned char* copy = new unsigned char[numBytes]; @@ -81,18 +80,15 @@ InetAddress::InetAddress(const std::string& hostname, { if (ipAddress == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "InetAddress constructor called with null address array."); } if (numBytes < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Number of bytes value is invalid: %d", - numBytes); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Number of bytes value is invalid: " + std::to_string(numBytes)); } unsigned char* copy = new unsigned char[numBytes]; diff --git a/activemq-cpp/src/main/decaf/net/ServerSocket.cpp b/activemq-cpp/src/main/decaf/net/ServerSocket.cpp index 46aab1150..cb45cbbe8 100644 --- a/activemq-cpp/src/main/decaf/net/ServerSocket.cpp +++ b/activemq-cpp/src/main/decaf/net/ServerSocket.cpp @@ -23,13 +23,15 @@ #include +#include #include +#include +#include using namespace decaf; using namespace decaf::io; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::internal::net::tcp; @@ -61,10 +63,9 @@ ServerSocket::ServerSocket(int port) { if (port < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Port value was invalid: %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Port value was invalid: " + std::to_string(port)); } this->impl = this->factory != NULL ? factory->createSocketImpl() @@ -84,10 +85,9 @@ ServerSocket::ServerSocket(int port, int backlog) { if (port < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Port value was invalid: %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Port value was invalid: " + std::to_string(port)); } this->impl = this->factory != NULL ? factory->createSocketImpl() @@ -107,10 +107,9 @@ ServerSocket::ServerSocket(int port, int backlog, const InetAddress* ifAddress) { if (port < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Port value was invalid: %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Port value was invalid: " + std::to_string(port)); } this->impl = this->factory != NULL ? factory->createSocketImpl() @@ -163,7 +162,6 @@ void ServerSocket::setupSocketImpl(int port, } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } @@ -176,7 +174,6 @@ void ServerSocket::bind(const std::string& host, int port) this->bind(host, port, getDefaultBacklog()); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCHALL_THROW(IOException) } @@ -187,11 +184,9 @@ void ServerSocket::bind(const std::string& address, int port, int backlog) if (port < 0 || port > 65535) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Specified port value is out of range: %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Specified port value is out of range: " + std::to_string(port)); } if (isBound()) @@ -216,7 +211,6 @@ void ServerSocket::bind(const std::string& address, int port, int backlog) } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } @@ -308,10 +302,9 @@ void ServerSocket::setReceiveBufferSize(int size) if (size <= 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Buffer size given was invalid: %d", - size); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Buffer size given was invalid: " + std::to_string(size)); } try @@ -320,7 +313,6 @@ void ServerSocket::setReceiveBufferSize(int size) this->impl->setOption(SocketOptions::SOCKET_OPTION_RCVBUF, size); } DECAF_CATCH_RETHROW(SocketException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, SocketException) DECAF_CATCHALL_THROW(SocketException) } @@ -381,10 +373,9 @@ void ServerSocket::setSoTimeout(int timeout) if (timeout < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Socket timeout given was invalid: %d", - timeout); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Socket timeout given was invalid: " + std::to_string(timeout)); } try @@ -393,7 +384,6 @@ void ServerSocket::setSoTimeout(int timeout) this->impl->setOption(SocketOptions::SOCKET_OPTION_TIMEOUT, timeout); } DECAF_CATCH_RETHROW(SocketException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, SocketException) DECAF_CATCHALL_THROW(SocketException) } diff --git a/activemq-cpp/src/main/decaf/net/ServerSocket.h b/activemq-cpp/src/main/decaf/net/ServerSocket.h index 3f894e668..3c7bb2be8 100644 --- a/activemq-cpp/src/main/decaf/net/ServerSocket.h +++ b/activemq-cpp/src/main/decaf/net/ServerSocket.h @@ -24,11 +24,10 @@ #include #include -#include -#include #include #include +#include #include namespace decaf @@ -93,7 +92,7 @@ namespace net * * @throws IOException if there is an I/O error while performing this * operation. - * @throws IllegalArgumentException if the port value is negative or + * @throws std::invalid_argument if the port value is negative or * greater than 65535. */ ServerSocket(int port); @@ -119,7 +118,7 @@ namespace net * * @throws IOException if there is an I/O error while performing this * operation. - * @throws IllegalArgumentException if the port value is negative or + * @throws std::invalid_argument if the port value is negative or * greater than 65535. */ ServerSocket(int port, int backlog); @@ -148,7 +147,7 @@ namespace net * * @throws IOException if there is an I/O error while performing this * operation. - * @throws IllegalArgumentException if the port value is negative or + * @throws std::invalid_argument if the port value is negative or * greater than 65535. */ ServerSocket(int port, int backlog, const InetAddress* address); @@ -168,7 +167,7 @@ namespace net * @param impl * The SocketImpl instance to wrap. * - * @throws NullPointerException if the passed SocketImpl is Null. + * @throws std::logic_error if the passed SocketImpl is Null. */ ServerSocket(SocketImpl* impl); @@ -184,7 +183,7 @@ namespace net * The TCP port between 1..655535. * * @throws IOException if an I/O error occurs while binding the socket. - * @throws IllegalArgumentException if the parameters are not valid. + * @throws std::invalid_argument if the parameters are not valid. */ virtual void bind(const std::string& host, int port); @@ -205,7 +204,7 @@ namespace net * The size of listen backlog. * * @throws IOException if an I/O error occurs while binding the socket. - * @throws IllegalArgumentException if the parameters are not valid. + * @throws std::invalid_argument if the parameters are not valid. */ virtual void bind(const std::string& host, int port, int backlog); @@ -263,7 +262,7 @@ namespace net * Number of bytes to set the receive buffer to. * * @throws SocketException if the operation fails. - * @throws IllegalArgumentException if the value is zero or negative. + * @throws std::invalid_argument if the value is zero or negative. */ virtual void setReceiveBufferSize(int size); @@ -303,7 +302,7 @@ namespace net * The timeout in milliseconds for socket operations. * * @throws SocketException Thrown if unable to set the information. - * @throws IllegalArgumentException if the timeout value is negative. + * @throws std::invalid_argument if the timeout value is negative. */ virtual void setSoTimeout(int timeout); diff --git a/activemq-cpp/src/main/decaf/net/Socket.cpp b/activemq-cpp/src/main/decaf/net/Socket.cpp index 5b0215327..e09182c7e 100644 --- a/activemq-cpp/src/main/decaf/net/Socket.cpp +++ b/activemq-cpp/src/main/decaf/net/Socket.cpp @@ -20,7 +20,10 @@ #include #include +#include #include +#include +#include using namespace decaf; using namespace decaf::net; @@ -29,7 +32,6 @@ using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::internal::net::tcp; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// SocketImplFactory* Socket::factory = NULL; @@ -65,9 +67,10 @@ Socket::Socket(SocketImpl* impl) { if (impl == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "SocketImpl pointer passed was Null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "SocketImpl pointer passed was Null."); } } @@ -83,7 +86,7 @@ Socket::Socket(const InetAddress* address, int port) { if (address == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The InetAddress to connect to cannot be NULL"); @@ -91,10 +94,9 @@ Socket::Socket(const InetAddress* address, int port) if (port < 0 || port > 65535) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Port specified is out of range: %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Port specified is out of range: " + std::to_string(port)); } try @@ -131,7 +133,7 @@ Socket::Socket(const InetAddress* address, { if (address == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The InetAddress to connect to cannot be NULL"); @@ -139,10 +141,9 @@ Socket::Socket(const InetAddress* address, if (port < 0 || port > 65535) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Port specified is out of range: %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Port specified is out of range: " + std::to_string(port)); } try @@ -179,10 +180,9 @@ Socket::Socket(const std::string& host, int port) { if (port < 0 || port > 65535) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Port specified is out of range: %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Port specified is out of range: " + std::to_string(port)); } try @@ -219,10 +219,9 @@ Socket::Socket(const std::string& host, { if (port < 0 || port > 65535) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Port specified is out of range: %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Port specified is out of range: " + std::to_string(port)); } try @@ -344,7 +343,6 @@ void Socket::bind(const std::string& ipaddress, int port) } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } @@ -366,10 +364,9 @@ void Socket::connect(const std::string& host, int port) { if (port < 0 || port > 65535) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Port specified is out of range: %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Port specified is out of range: " + std::to_string(port)); } try @@ -377,7 +374,6 @@ void Socket::connect(const std::string& host, int port) this->connect(host, port, 0); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCHALL_THROW(IOException) } @@ -388,10 +384,9 @@ void Socket::connect(const std::string& host, int port, int timeout) if (timeout < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Timeout value specified is invalid: %d", - timeout); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Timeout value specified is invalid: " + std::to_string(timeout)); } if (isConnected()) @@ -403,9 +398,9 @@ void Socket::connect(const std::string& host, int port, int timeout) if (host.empty()) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Host cannot be empty."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Host cannot be empty."); } try @@ -433,7 +428,6 @@ void Socket::connect(const std::string& host, int port, int timeout) } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } @@ -550,18 +544,15 @@ void Socket::setSoLinger(bool state, int timeout) if (state && timeout < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Timeout value passed is invalid: %d", - timeout); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Timeout value passed is invalid: " + std::to_string(timeout)); } int value = state ? (65535 > timeout ? timeout : 65535) : -1; this->impl->setOption(SocketOptions::SOCKET_OPTION_LINGER, value); } DECAF_CATCH_RETHROW(SocketException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, SocketException) DECAF_CATCHALL_THROW(SocketException) } @@ -622,10 +613,9 @@ void Socket::setReceiveBufferSize(int size) if (size <= 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Buffer size given was invalid: %d", - size); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Buffer size given was invalid: " + std::to_string(size)); } try @@ -634,7 +624,6 @@ void Socket::setReceiveBufferSize(int size) this->impl->setOption(SocketOptions::SOCKET_OPTION_RCVBUF, size); } DECAF_CATCH_RETHROW(SocketException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, SocketException) DECAF_CATCHALL_THROW(SocketException) } @@ -695,10 +684,9 @@ void Socket::setSendBufferSize(int size) if (size <= 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Buffer size given was invalid: %d", - size); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Buffer size given was invalid: " + std::to_string(size)); } try @@ -707,7 +695,6 @@ void Socket::setSendBufferSize(int size) this->impl->setOption(SocketOptions::SOCKET_OPTION_SNDBUF, size); } DECAF_CATCH_RETHROW(SocketException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, SocketException) DECAF_CATCHALL_THROW(SocketException) } @@ -734,10 +721,9 @@ void Socket::setSoTimeout(int timeout) if (timeout < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Socket timeout given was invalid: %d", - timeout); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Socket timeout given was invalid: " + std::to_string(timeout)); } try @@ -746,7 +732,6 @@ void Socket::setSoTimeout(int timeout) this->impl->setOption(SocketOptions::SOCKET_OPTION_TIMEOUT, timeout); } DECAF_CATCH_RETHROW(SocketException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, SocketException) DECAF_CATCHALL_THROW(SocketException) } @@ -807,11 +792,10 @@ void Socket::setTrafficClass(int value) if (value < 0 || value > 255) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Value of the Traffic class option was invalid: %d", - value); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Value of the Traffic class option was invalid: " + + std::to_string(value)); } try @@ -820,7 +804,6 @@ void Socket::setTrafficClass(int value) this->impl->setOption(SocketOptions::SOCKET_OPTION_IP_TOS, value); } DECAF_CATCH_RETHROW(SocketException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, SocketException) DECAF_CATCHALL_THROW(SocketException) } diff --git a/activemq-cpp/src/main/decaf/net/Socket.h b/activemq-cpp/src/main/decaf/net/Socket.h index 94264f21a..4edf460b4 100644 --- a/activemq-cpp/src/main/decaf/net/Socket.h +++ b/activemq-cpp/src/main/decaf/net/Socket.h @@ -26,10 +26,9 @@ #include #include -#include -#include #include #include +#include namespace decaf { @@ -83,7 +82,7 @@ namespace net * @param impl * The SocketImpl instance to wrap. * - * @throws NullPointerException if the passed SocketImpl is Null. + * @throws std::logic_error if the passed SocketImpl is Null. */ Socket(SocketImpl* impl); @@ -103,8 +102,8 @@ namespace net * @throws UnknownHostException if the host cannot be resolved. * @throws IOException if an I/O error occurs while connecting the * Socket. - * @throws NullPointerException if the InetAddress instance in NULL. - * @throws IllegalArgumentException if the port if not in range + * @throws std::logic_error if the InetAddress instance in NULL. + * @throws std::invalid_argument if the port if not in range * [0...65535] */ Socket(const InetAddress* address, int port); @@ -128,8 +127,8 @@ namespace net * @throws UnknownHostException if the host cannot be resolved. * @throws IOException if an I/O error occurs while connecting the * Socket. - * @throws NullPointerException if the InetAddress instance in NULL. - * @throws IllegalArgumentException if the port if not in range + * @throws std::logic_error if the InetAddress instance in NULL. + * @throws std::invalid_argument if the port if not in range * [0...65535] */ Socket(const InetAddress* address, @@ -154,7 +153,7 @@ namespace net * @throws UnknownHostException if the host cannot be resolved. * @throws IOException if an I/O error occurs while connecting the * Socket. - * @throws IllegalArgumentException if the port if not in range + * @throws std::invalid_argument if the port if not in range * [0...65535] */ Socket(const std::string& host, int port); @@ -180,7 +179,7 @@ namespace net * @throws UnknownHostException if the host cannot be resolved. * @throws IOException if an I/O error occurs while connecting the * Socket. - * @throws IllegalArgumentException if the port if not in range + * @throws std::invalid_argument if the port if not in range * [0...65535] */ Socket(const std::string& host, @@ -201,7 +200,7 @@ namespace net * The port on the local machine to bind to. * * @throws IOException if an error occurs during the bind operation. - * @throws IllegalArgumentException if the Socket can't process the + * @throws std::invalid_argument if the Socket can't process the * subclass of SocketAddress that has been provided. */ virtual void bind(const std::string& ipaddress, int port); @@ -398,7 +397,7 @@ namespace net * The linger time in seconds, must be non-negative. * * @throws SocketException if the operation fails. - * @throws IllegalArgumentException if state is true and timeout is + * @throws std::invalid_argument if state is true and timeout is * negative. */ virtual void setSoLinger(bool state, int timeout); @@ -440,7 +439,7 @@ namespace net * Number of bytes to set the receive buffer to. * * @throws SocketException if the operation fails. - * @throws IllegalArgumentException if the value is zero or negative. + * @throws std::invalid_argument if the value is zero or negative. */ virtual void setReceiveBufferSize(int size); @@ -482,7 +481,7 @@ namespace net * than zero. * * @throws SocketException if the operation fails. - * @throws IllegalArgumentException if the value is zero or negative. + * @throws std::invalid_argument if the value is zero or negative. */ virtual void setSendBufferSize(int size); @@ -503,7 +502,7 @@ namespace net * The timeout in milliseconds for socket operations. * * @throws SocketException Thrown if unable to set the information. - * @throws IllegalArgumentException if the timeout value is negative. + * @throws std::invalid_argument if the timeout value is negative. */ virtual void setSoTimeout(int timeout); @@ -557,7 +556,7 @@ namespace net * * @throws SocketException if an error is encountered while performing * this operation. - * @throws IllegalArgumentException if the value is not in the range + * @throws std::invalid_argument if the value is not in the range * [0..255]. */ virtual void setTrafficClass(int value); diff --git a/activemq-cpp/src/main/decaf/net/URI.cpp b/activemq-cpp/src/main/decaf/net/URI.cpp index 4a9149d93..f455a172c 100644 --- a/activemq-cpp/src/main/decaf/net/URI.cpp +++ b/activemq-cpp/src/main/decaf/net/URI.cpp @@ -17,12 +17,15 @@ #include "URI.h" +#include #include #include #include #include #include #include +#include +#include using namespace std; using namespace decaf; @@ -31,7 +34,6 @@ using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::internal::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// const std::string URI::unreserved = "_-!.~\'()*"; @@ -614,7 +616,7 @@ URI URI::create(const std::string uri) } catch (URISyntaxException& e) { - throw IllegalArgumentException(e); + throw activemq::exceptions::InvalidArgumentException(e.getMessage()); } } @@ -1107,9 +1109,8 @@ URL URI::toURL() const { if (!this->isAbsolute()) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "URI is not absolute, cannot convert to an URL."); } diff --git a/activemq-cpp/src/main/decaf/net/URI.h b/activemq-cpp/src/main/decaf/net/URI.h index fc701ec97..52d8c03ba 100644 --- a/activemq-cpp/src/main/decaf/net/URI.h +++ b/activemq-cpp/src/main/decaf/net/URI.h @@ -20,10 +20,10 @@ #include #include -#include #include #include #include +#include #include namespace decaf @@ -387,7 +387,7 @@ namespace net * * @return The resulting URI * - * @throws IllegalArgumentException - If the given string violates RFC + * @throws std::invalid_argument - If the given string violates RFC * 2396 */ URI resolve(const std::string& str) const; @@ -458,7 +458,7 @@ namespace net * * @return A URL constructed from this URI * - * @throws IllegalArgumentException - If this URL is not absolute + * @throws std::invalid_argument - If this URL is not absolute * @throws MalformedURLException - If a protocol handler for the URL * could not be found, or if some other error occurred while * constructing the URL @@ -470,12 +470,12 @@ namespace net * Creates a URI by parsing the given string. * This convenience factory method works as if by invoking the * URI(string) constructor; any URISyntaxException thrown by the - * constructor is caught and wrapped in a new IllegalArgumentException + * constructor is caught and wrapped in a new std::invalid_argument * object, which is then thrown. * * @param uri - URI string to parse * - * @throws IllegalArgumentException + * @throws std::invalid_argument */ static URI create(const std::string uri); diff --git a/activemq-cpp/src/main/decaf/net/URL.cpp b/activemq-cpp/src/main/decaf/net/URL.cpp index c00be6a16..2ac3c9d83 100644 --- a/activemq-cpp/src/main/decaf/net/URL.cpp +++ b/activemq-cpp/src/main/decaf/net/URL.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -33,6 +32,10 @@ #include +#include +#include +#include + using namespace std; using namespace decaf; using namespace decaf::io; @@ -42,7 +45,6 @@ using namespace decaf::internal::net; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::net; @@ -260,6 +262,10 @@ void URL::initialize(const URL* context, { throw MalformedURLException(__FILE__, __LINE__, e.getMessage().c_str()); } + catch (std::exception& e) + { + throw MalformedURLException(__FILE__, __LINE__, e.what()); + } if (impl->url.getPort() < -1) { @@ -293,10 +299,10 @@ void URL::initialize(const String& protocol, if (protocol.isEmpty()) { - throw NullPointerException(__FILE__, - __LINE__, - "Unknown protocol: %s", - "NULL"); + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + "Unknown protocol: " + "NULL"); } String theHost; @@ -453,9 +459,9 @@ URLConnection* URL::openConnection(const Proxy* proxy) { if (proxy == NULL) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "proxy should not be NULL"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "proxy should not be NULL"); } return impl->streamHandler->openConnection(*this, proxy); diff --git a/activemq-cpp/src/main/decaf/net/URL.h b/activemq-cpp/src/main/decaf/net/URL.h index a7fef6a5d..2fec32d88 100644 --- a/activemq-cpp/src/main/decaf/net/URL.h +++ b/activemq-cpp/src/main/decaf/net/URL.h @@ -22,6 +22,7 @@ #include #include +#include #include namespace decaf @@ -430,9 +431,9 @@ namespace net * @return a new URLConnection instance for this URL. * * @throws IOException if an error occurs while opening the connection. - * @throws IllegalArgumentException if proxy is null, or proxy has the + * @throws std::invalid_argument if proxy is null, or proxy has the * wrong type. - * @throws UnsupportedOperationException if this method is not + * @throws std::logic_error if this method is not * supported. */ URLConnection* openConnection(const Proxy* proxy); diff --git a/activemq-cpp/src/main/decaf/net/URLConnection.cpp b/activemq-cpp/src/main/decaf/net/URLConnection.cpp index 7dfff4931..6dc3cdc1c 100644 --- a/activemq-cpp/src/main/decaf/net/URLConnection.cpp +++ b/activemq-cpp/src/main/decaf/net/URLConnection.cpp @@ -19,15 +19,14 @@ #include #include -#include -#include -#include -#include + +#include +#include +#include using namespace decaf; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// bool URLConnection::defaultAllowUserInteraction; @@ -110,9 +109,10 @@ long long URLConnection::getHeaderFieldDate(const std::string& field, return defaultValue; } - throw UnsupportedOperationException(__FILE__, - __LINE__, - "Not yet implemented"); + throw activemq::exceptions::UnsupportedOperationException( + __FILE__, + __LINE__, + "Not yet implemented"); try { @@ -133,7 +133,7 @@ int URLConnection::getHeaderFieldInt(const std::string& field, { return Integer::parseInt(getHeaderField(field)); } - catch (NumberFormatException& e) + catch (std::invalid_argument&) { return defaultValue; } @@ -144,9 +144,10 @@ void URLConnection::setAllowUserInteraction(bool newValue) { if (connected) { - throw IllegalStateException(__FILE__, - __LINE__, - "Connection already established"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Connection already established"); } allowUserInteraction = newValue; @@ -157,9 +158,10 @@ void URLConnection::setDefaultUseCaches(bool newValue) { if (connected) { - throw IllegalStateException(__FILE__, - __LINE__, - "Connection already established"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Connection already established"); } defaultUseCaches = newValue; } @@ -169,9 +171,10 @@ void URLConnection::setDoInput(bool newValue) { if (connected) { - throw IllegalStateException(__FILE__, - __LINE__, - "Connection already established"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Connection already established"); } doInput = newValue; } @@ -181,9 +184,10 @@ void URLConnection::setDoOutput(bool newValue) { if (connected) { - throw IllegalStateException(__FILE__, - __LINE__, - "Connection already established"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Connection already established"); } doOutput = newValue; } @@ -193,9 +197,10 @@ void URLConnection::setUseCaches(bool newValue) { if (connected) { - throw IllegalStateException(__FILE__, - __LINE__, - "Connection already established"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Connection already established"); } useCaches = newValue; } @@ -205,9 +210,10 @@ void URLConnection::setConnectTimeout(int timeout) { if (0 > timeout) { - throw IllegalStateException(__FILE__, - __LINE__, - "Invalid negative timeout"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Invalid negative timeout"); } impl->connectTimeout = timeout; } @@ -217,9 +223,10 @@ void URLConnection::setReadTimeout(int timeout) { if (0 > timeout) { - throw IllegalStateException(__FILE__, - __LINE__, - "Invalid negative timeout"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Invalid negative timeout"); } impl->readTimeout = timeout; } @@ -240,9 +247,10 @@ void URLConnection::setIfModifiedSince(long long newValue) { if (connected) { - throw IllegalStateException(__FILE__, - __LINE__, - "Connection already established"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Connection already established"); } ifModifiedSince = newValue; } diff --git a/activemq-cpp/src/main/decaf/net/URLConnection.h b/activemq-cpp/src/main/decaf/net/URLConnection.h index eb8956c37..14506f59e 100644 --- a/activemq-cpp/src/main/decaf/net/URLConnection.h +++ b/activemq-cpp/src/main/decaf/net/URLConnection.h @@ -24,6 +24,7 @@ #include #include #include +#include namespace decaf { @@ -125,7 +126,7 @@ namespace net * * @param newValue * the value of the flag to be set. - * @throws IllegalStateException + * @throws std::logic_error * if this method attempts to change the flag after the connection * has been established. */ @@ -281,7 +282,7 @@ namespace net * * @param newValue * the value of the flag to be set. - * @throws IllegalStateException + * @throws std::logic_error * if this method attempts to change the flag after the connection * has been established. */ @@ -303,7 +304,7 @@ namespace net * * @param timeout * the connecting timeout in milliseconds. - * @throws IllegalArgumentException + * @throws std::invalid_argument * if the parameter timeout is less than zero. */ void setConnectTimeout(int timeout); @@ -325,7 +326,7 @@ namespace net * * @param timeout * the reading timeout in milliseconds. - * @throws IllegalArgumentException + * @throws std::invalid_argument * if the parameter timeout is less than zero. */ void setReadTimeout(int timeout); @@ -464,7 +465,7 @@ namespace net * * @param newValue * the time in milliseconds since January 1, 1970 GMT. - * @throws IllegalStateException + * @throws std::logic_error * if this URLConnection has already been connected. */ void setIfModifiedSince(long long newValue); diff --git a/activemq-cpp/src/main/decaf/net/URLDecoder.cpp b/activemq-cpp/src/main/decaf/net/URLDecoder.cpp index e08ed1282..db5ed25cc 100644 --- a/activemq-cpp/src/main/decaf/net/URLDecoder.cpp +++ b/activemq-cpp/src/main/decaf/net/URLDecoder.cpp @@ -17,12 +17,14 @@ #include "URLDecoder.h" #include -#include + +#include +#include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::net; //////////////////////////////////////////////////////////////////////////////// @@ -49,11 +51,10 @@ std::string URLDecoder::decode(const std::string& src) { if (i + 2 >= src.length()) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Incomplete % sequence at: %d.", - i); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": Incomplete % sequence at: " + std::to_string(i) + + "."); } int d1 = Character::digit(src.at(i + 1), 16); @@ -61,12 +62,10 @@ std::string URLDecoder::decode(const std::string& src) if (d1 == -1 || d2 == -1) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Invalid % sequence (%s) at: %d.", - src.substr(i, 3).c_str(), - i); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": Invalid % sequence (" + src.substr(i, 3) + + ") at: " + std::to_string(i) + "."); } decoded += (char)((d1 << 4) + d2); diff --git a/activemq-cpp/src/main/decaf/net/URLStreamHandler.cpp b/activemq-cpp/src/main/decaf/net/URLStreamHandler.cpp index 6453e2ff3..55bb50e2c 100644 --- a/activemq-cpp/src/main/decaf/net/URLStreamHandler.cpp +++ b/activemq-cpp/src/main/decaf/net/URLStreamHandler.cpp @@ -17,19 +17,18 @@ #include +#include #include #include #include -#include -#include -#include #include #include +#include +#include using namespace decaf; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::util; using namespace decaf::internal::net; @@ -65,9 +64,10 @@ String relativePath(const String& base, const String& path) URLConnection* URLStreamHandler::openConnection(const URL& url DECAF_UNUSED, const Proxy* proxy DECAF_UNUSED) { - throw UnsupportedOperationException(__FILE__, - __LINE__, - "method has not been implemented yet"); + throw activemq::exceptions::UnsupportedOperationException( + __FILE__, + __LINE__, + "method has not been implemented yet"); } //////////////////////////////////////////////////////////////////////////////// @@ -227,13 +227,16 @@ void URLStreamHandler::parseURL(URL& url, (spec.startsWith("//", start) && spec.indexOf('/', start + 2) == -1)) { - throw StringIndexOutOfBoundsException(__FILE__, __LINE__, limit); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid limit: " + std::to_string(limit)); } if (this != url.getURLStreamHandler()) { - throw SecurityException(__FILE__, - __LINE__, - "Only the URL's stream handler can modify"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Only the URL's stream handler can modify"); } return; } @@ -279,12 +282,10 @@ void URLStreamHandler::parseURL(URL& url, { if (URLUtils::findFirstOf(spec, ":", hostStart, ipv6End) == ipv6End) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - (std::string("Expected an IPv6 address: ") + - spec.substring(hostStart, ipv6End + 1).toString()) - .c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": Expected an IPv6 address: " + + spec.substring(hostStart, ipv6End + 1).toString()); } colonSearchFrom = ipv6End; } @@ -298,10 +299,9 @@ void URLStreamHandler::parseURL(URL& url, spec.substring(portStart, fileStart).toString()); if (port < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "port < 0: %d", - port); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": port < 0: " + std::to_string(port)); } } path = ""; @@ -378,9 +378,10 @@ void URLStreamHandler::setURL(URL& url, { if (this != url.getURLStreamHandler()) { - throw SecurityException(__FILE__, - __LINE__, - "Stream handler is not the URLs intance."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Stream handler is not the URLs instance."); } url.set(protocol, host, port, authority, userInfo, path, query, ref); diff --git a/activemq-cpp/src/main/decaf/net/URLStreamHandler.h b/activemq-cpp/src/main/decaf/net/URLStreamHandler.h index bba8d42bb..139c2393b 100644 --- a/activemq-cpp/src/main/decaf/net/URLStreamHandler.h +++ b/activemq-cpp/src/main/decaf/net/URLStreamHandler.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace decaf { @@ -84,7 +85,7 @@ namespace net * * @throws IOException if an I/O error occurs during opening the * connection. - * @throws UnsupportedOperationException if the protocol in use doesn't + * @throws std::logic_error if the protocol in use doesn't * support this. */ virtual URLConnection* openConnection(const URL& url, @@ -219,7 +220,7 @@ namespace net * @param ref * the internal reference in the URL * - * @throws SecurityException if the protocol handler of the URL is not + * @throws std::logic_error if the protocol handler of the URL is not * this instance. */ void setURL(URL& url, diff --git a/activemq-cpp/src/main/decaf/net/ssl/SSLContext.cpp b/activemq-cpp/src/main/decaf/net/ssl/SSLContext.cpp index 1333ba26c..e5b3d24f9 100644 --- a/activemq-cpp/src/main/decaf/net/ssl/SSLContext.cpp +++ b/activemq-cpp/src/main/decaf/net/ssl/SSLContext.cpp @@ -17,19 +17,18 @@ #include "SSLContext.h" -#include -#include - #include #include +#include #include +#include +#include using namespace decaf; using namespace decaf::net; using namespace decaf::net::ssl; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal; using namespace decaf::internal::net; using namespace decaf::internal::net::ssl; @@ -43,9 +42,10 @@ SSLContext::SSLContext(SSLContextSpi* contextImpl) { if (contextImpl == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "SSLContextSpi cannot be NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "SSLContextSpi cannot be NULL"); } } @@ -72,9 +72,32 @@ SSLContext* SSLContext::getDefault() return DefaultSSLContext::getContext(); } - DECAF_CATCH_RETHROW(IllegalStateException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IllegalStateException) - DECAF_CATCHALL_THROW(IllegalStateException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::IllegalStateException(ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -82,9 +105,10 @@ void SSLContext::setDefault(SSLContext* context) { if (context == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "SSLContextSpi cannot be NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "SSLContextSpi cannot be NULL"); } SSLContext::defaultSSLContext = context; @@ -97,9 +121,32 @@ SocketFactory* SSLContext::getSocketFactory() { return this->contextImpl->providerGetSocketFactory(); } - DECAF_CATCH_RETHROW(IllegalStateException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IllegalStateException) - DECAF_CATCHALL_THROW(IllegalStateException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::IllegalStateException(ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -109,9 +156,32 @@ ServerSocketFactory* SSLContext::getServerSocketFactory() { return this->contextImpl->providerGetServerSocketFactory(); } - DECAF_CATCH_RETHROW(IllegalStateException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IllegalStateException) - DECAF_CATCHALL_THROW(IllegalStateException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::IllegalStateException(ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -121,9 +191,32 @@ SSLParameters* SSLContext::getDefaultSSLParameters() { return this->contextImpl->providerGetDefaultSSLParameters(); } - DECAF_CATCH_RETHROW(IllegalStateException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IllegalStateException) - DECAF_CATCHALL_THROW(IllegalStateException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::IllegalStateException(ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -133,7 +226,30 @@ SSLParameters* SSLContext::getSupportedSSLParameters() { return this->contextImpl->providerGetSupportedSSLParameters(); } - DECAF_CATCH_RETHROW(IllegalStateException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IllegalStateException) - DECAF_CATCHALL_THROW(IllegalStateException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::IllegalStateException(ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } diff --git a/activemq-cpp/src/main/decaf/net/ssl/SSLContext.h b/activemq-cpp/src/main/decaf/net/ssl/SSLContext.h index 141d4dbd5..2c7781678 100644 --- a/activemq-cpp/src/main/decaf/net/ssl/SSLContext.h +++ b/activemq-cpp/src/main/decaf/net/ssl/SSLContext.h @@ -21,6 +21,7 @@ #include #include +#include namespace decaf { @@ -69,7 +70,7 @@ namespace net * caller is responsible for deleting this object before the Library * shutdown methods are called. * - * @throws NullPointerException if the context passed is NULL. + * @throws std::logic_error if the context passed is NULL. */ static void setDefault(SSLContext* context); @@ -86,7 +87,7 @@ namespace net * @return a pointer to this SSLContext's SocketFactory for creating * SSLSocket objects. * - * @throws IllegalStateException if the SSLContextSpi requires + * @throws std::logic_error if the SSLContextSpi requires * initialization but it has not yet been initialized. */ SocketFactory* getSocketFactory(); @@ -99,7 +100,7 @@ namespace net * @return a pointer to this SSLContext's ServerSocketFactory for * creating SSLServerSocket objects. * - * @throws IllegalStateException if the SSLContextSpi requires + * @throws std::logic_error if the SSLContextSpi requires * initialization but it has not yet been initialized. */ ServerSocketFactory* getServerSocketFactory(); @@ -108,7 +109,7 @@ namespace net * @return a new instance of an SSLParameters object containing the * default set of settings for this SSLContext. * - * @throws UnsupportedOperationException if the parameters cannot be + * @throws std::logic_error if the parameters cannot be * retrieved. */ SSLParameters* getDefaultSSLParameters(); @@ -117,7 +118,7 @@ namespace net * @return a new instance of an SSLParameters object containing the * complete set of settings for this SSLContext. * - * @throws UnsupportedOperationException if the parameters cannot be + * @throws std::logic_error if the parameters cannot be * retrieved. */ SSLParameters* getSupportedSSLParameters(); diff --git a/activemq-cpp/src/main/decaf/net/ssl/SSLContextSpi.cpp b/activemq-cpp/src/main/decaf/net/ssl/SSLContextSpi.cpp index 94d17d2d7..0b1b0e4e0 100644 --- a/activemq-cpp/src/main/decaf/net/ssl/SSLContextSpi.cpp +++ b/activemq-cpp/src/main/decaf/net/ssl/SSLContextSpi.cpp @@ -21,15 +21,15 @@ #include #include -#include - +#include #include +#include +#include using namespace decaf; using namespace decaf::net; using namespace decaf::net::ssl; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// SSLContextSpi::~SSLContextSpi() @@ -60,9 +60,32 @@ SSLParameters* SSLContextSpi::providerGetSupportedSSLParameters() return params.release(); } - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::TypeMismatchException(ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::TypeMismatchException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -88,7 +111,30 @@ SSLParameters* SSLContextSpi::providerGetDefaultSSLParameters() return params.release(); } - DECAF_CATCH_RETHROW(UnsupportedOperationException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, UnsupportedOperationException) - DECAF_CATCHALL_THROW(UnsupportedOperationException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::TypeMismatchException(ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::TypeMismatchException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } diff --git a/activemq-cpp/src/main/decaf/net/ssl/SSLContextSpi.h b/activemq-cpp/src/main/decaf/net/ssl/SSLContextSpi.h index d09a8db77..3d69f3cf7 100644 --- a/activemq-cpp/src/main/decaf/net/ssl/SSLContextSpi.h +++ b/activemq-cpp/src/main/decaf/net/ssl/SSLContextSpi.h @@ -21,6 +21,7 @@ #include #include +#include namespace decaf { @@ -52,7 +53,7 @@ namespace net * @param random * Pointer to an instance of a secure random number generator. * - * @throw NullPointerException if the SecureRandom instance is NULL. + * @throw std::logic_error if the SecureRandom instance is NULL. * @throw KeyManagementException if an error occurs while * initializing the context. */ @@ -67,7 +68,7 @@ namespace net * * @return new SSLParameters instance with the SSLContext defaults. * - * @throws UnsupportedOperationException if the defaults cannot be + * @throws std::logic_error if the defaults cannot be * obtained. */ virtual SSLParameters* providerGetDefaultSSLParameters(); @@ -82,7 +83,7 @@ namespace net * @return a new SSLParameters instance with the full set of * settings that are supported. * - * @throws UnsupportedOperationException if the supported parameters + * @throws std::logic_error if the supported parameters * cannot be obtained. */ virtual SSLParameters* providerGetSupportedSSLParameters(); @@ -97,7 +98,7 @@ namespace net * @return SocketFactory instance that can be used to create new * SSLSockets. * - * @throws IllegalStateException if the SSLContextSpi object + * @throws std::logic_error if the SSLContextSpi object * requires initialization but has not been initialized yet. */ virtual SocketFactory* providerGetSocketFactory() = 0; @@ -112,7 +113,7 @@ namespace net * @return SocketFactory instance that can be used to create new * SSLServerSockets. * - * @throws IllegalStateException if the SSLContextSpi object + * @throws std::logic_error if the SSLContextSpi object * requires initialization but has not been initialized yet. */ virtual ServerSocketFactory* providerGetServerSocketFactory() = 0; diff --git a/activemq-cpp/src/main/decaf/net/ssl/SSLServerSocket.cpp b/activemq-cpp/src/main/decaf/net/ssl/SSLServerSocket.cpp index 62a1ecac0..585e64b70 100644 --- a/activemq-cpp/src/main/decaf/net/ssl/SSLServerSocket.cpp +++ b/activemq-cpp/src/main/decaf/net/ssl/SSLServerSocket.cpp @@ -18,13 +18,11 @@ #include "SSLServerSocket.h" #include -#include using namespace decaf; using namespace decaf::net; using namespace decaf::net::ssl; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// SSLServerSocket::SSLServerSocket() diff --git a/activemq-cpp/src/main/decaf/net/ssl/SSLServerSocket.h b/activemq-cpp/src/main/decaf/net/ssl/SSLServerSocket.h index a3a4ba2ce..164eda31d 100644 --- a/activemq-cpp/src/main/decaf/net/ssl/SSLServerSocket.h +++ b/activemq-cpp/src/main/decaf/net/ssl/SSLServerSocket.h @@ -21,6 +21,7 @@ #include #include +#include namespace decaf { @@ -62,7 +63,7 @@ namespace net * * @throws IOException if there is an I/O error while performing * this operation. - * @throws IllegalArgumentException if the port value is negative or + * @throws std::invalid_argument if the port value is negative or * greater than 65535. */ SSLServerSocket(int port); @@ -88,7 +89,7 @@ namespace net * * @throws IOException if there is an I/O error while performing * this operation. - * @throws IllegalArgumentException if the port value is negative or + * @throws std::invalid_argument if the port value is negative or * greater than 65535. */ SSLServerSocket(int port, int backlog); @@ -117,7 +118,7 @@ namespace net * * @throws IOException if there is an I/O error while performing * this operation. - * @throws IllegalArgumentException if the port value is negative or + * @throws std::invalid_argument if the port value is negative or * greater than 65535. */ SSLServerSocket(int port, @@ -165,7 +166,7 @@ namespace net * An Vector of names for all the Cipher Suites that are to be * enabled. * - * @throws IllegalArgumentException if the vector is empty or one of + * @throws std::invalid_argument if the vector is empty or one of * the names is invalid. */ virtual void setEnabledCipherSuites( @@ -189,7 +190,7 @@ namespace net * An Vector of names for all the Protocols that are to be * enabled. * - * @throws IllegalArgumentException if the vector is empty or one of + * @throws std::invalid_argument if the vector is empty or one of * the names is invalid. */ virtual void setEnabledProtocols( diff --git a/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.cpp b/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.cpp index a0ec49ea3..81b894a09 100644 --- a/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.cpp +++ b/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.cpp @@ -16,14 +16,14 @@ */ #include "SSLSocket.h" - -#include +#include +#include +#include using namespace decaf; using namespace decaf::net; using namespace decaf::net::ssl; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// SSLSocket::SSLSocket() @@ -90,7 +90,14 @@ void SSLSocket::setSSLParameters(const SSLParameters& value) this->setEnabledProtocols(value.getProtocols()); } } - DECAF_CATCH_RETHROW(IllegalArgumentException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IllegalArgumentException) - DECAF_CATCHALL_THROW(IllegalArgumentException) + catch (Exception& ex) + { + throw activemq::exceptions::InvalidArgumentException(ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } diff --git a/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.h b/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.h index 1cd746728..f9d746874 100644 --- a/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.h +++ b/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.h @@ -22,6 +22,7 @@ #include #include +#include namespace decaf { @@ -54,8 +55,8 @@ namespace net * @throws UnknownHostException if the host cannot be resolved. * @throws IOException if an I/O error occurs while connecting the * Socket. - * @throws NullPointerException if the InetAddress instance in NULL. - * @throws IllegalArgumentException if the port if not in range + * @throws std::logic_error if the InetAddress instance in NULL. + * @throws std::invalid_argument if the port if not in range * [0...65535] */ SSLSocket(const InetAddress* address, int port); @@ -77,8 +78,8 @@ namespace net * @throws UnknownHostException if the host cannot be resolved. * @throws IOException if an I/O error occurs while connecting the * Socket. - * @throws NullPointerException if the InetAddress instance in NULL. - * @throws IllegalArgumentException if the port if not in range + * @throws std::logic_error if the InetAddress instance in NULL. + * @throws std::invalid_argument if the port if not in range * [0...65535] */ SSLSocket(const InetAddress* address, @@ -102,7 +103,7 @@ namespace net * @throws UnknownHostException if the host cannot be resolved. * @throws IOException if an I/O error occurs while connecting the * Socket. - * @throws IllegalArgumentException if the port if not in range + * @throws std::invalid_argument if the port if not in range * [0...65535] */ SSLSocket(const std::string& host, int port); @@ -127,7 +128,7 @@ namespace net * @throws UnknownHostException if the host cannot be resolved. * @throws IOException if an I/O error occurs while connecting the * Socket. - * @throws IllegalArgumentException if the port if not in range + * @throws std::invalid_argument if the port if not in range * [0...65535] */ SSLSocket(const std::string& host, @@ -176,7 +177,7 @@ namespace net * An Vector of names for all the Cipher Suites that are to be * enabled. * - * @throws IllegalArgumentException if the vector is empty or one of + * @throws std::invalid_argument if the vector is empty or one of * the names is invalid. */ virtual void setEnabledCipherSuites( @@ -200,7 +201,7 @@ namespace net * An Vector of names for all the Protocols that are to be * enabled. * - * @throws IllegalArgumentException if the vector is empty or one of + * @throws std::invalid_argument if the vector is empty or one of * the names is invalid. */ virtual void setEnabledProtocols( @@ -234,7 +235,7 @@ namespace net * The SSLParameters instance that is used to update this * SSLSocket's settings. * - * @throws IllegalArgumentException if an error occurs while calling + * @throws std::invalid_argument if an error occurs while calling * setEnabledCipherSuites or setEnabledProtocols. */ virtual void setSSLParameters(const SSLParameters& value); diff --git a/activemq-cpp/src/main/decaf/nio/Buffer.cpp b/activemq-cpp/src/main/decaf/nio/Buffer.cpp index 4fb0aa91a..db816fb28 100644 --- a/activemq-cpp/src/main/decaf/nio/Buffer.cpp +++ b/activemq-cpp/src/main/decaf/nio/Buffer.cpp @@ -16,13 +16,12 @@ */ #include "Buffer.h" - -#include +#include +#include +#include using namespace decaf; using namespace decaf::nio; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// Buffer::Buffer(int capacity) @@ -49,9 +48,8 @@ Buffer& Buffer::position(int newPosition) { if (newPosition < 0 || newPosition > this->_limit) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Buffer::position - New Position is greater than set limit"); } @@ -70,9 +68,8 @@ Buffer& Buffer::limit(int newLimit) { if (newLimit < 0 || newLimit > this->capacity()) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Buffer::limit - new limit is larger than the capacity."); } diff --git a/activemq-cpp/src/main/decaf/nio/Buffer.h b/activemq-cpp/src/main/decaf/nio/Buffer.h index 407989307..8a2ac1359 100644 --- a/activemq-cpp/src/main/decaf/nio/Buffer.h +++ b/activemq-cpp/src/main/decaf/nio/Buffer.h @@ -18,8 +18,8 @@ #ifndef _DECAF_NIO_BUFFER_H_ #define _DECAF_NIO_BUFFER_H_ -#include #include +#include namespace decaf { @@ -57,7 +57,7 @@ namespace nio * no data is transferred. * * Absolute operations take an explicit element index and do not affect * the position. Absolute get and put operations throw an - * IndexOutOfBoundsException if the index argument exceeds the limit. + * std::out_of_range if the index argument exceeds the limit. * * Data may also, of course, be transferred in to or out of a buffer by the * I/O operations of an appropriate channel, which are always relative to @@ -173,7 +173,7 @@ namespace nio * * @return a reference to This buffer. * - * @throws IllegalArgumentException if preconditions on the new pos + * @throws std::invalid_argument if preconditions on the new pos * don't hold. */ virtual Buffer& position(int newPosition); @@ -197,7 +197,7 @@ namespace nio * * @return A reference to This buffer * - * @throws IllegalArgumentException if preconditions on the new pos + * @throws std::invalid_argument if preconditions on the new pos * don't hold. */ virtual Buffer& limit(int newLimit); diff --git a/activemq-cpp/src/main/decaf/nio/BufferUnderflowException.h b/activemq-cpp/src/main/decaf/nio/BufferUnderflowException.h deleted file mode 100644 index e6271a03c..000000000 --- a/activemq-cpp/src/main/decaf/nio/BufferUnderflowException.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DECAF_NIO_BUFFERUNDERFLOWEXCEPTION_H_ -#define _DECAF_NIO_BUFFERUNDERFLOWEXCEPTION_H_ - -#include -#include - -namespace decaf -{ -namespace nio -{ - - class DECAF_API BufferUnderflowException : public lang::Exception - { - public: - /** - * Default Constructor - */ - BufferUnderflowException(); - - /** - * Copy Constructor - * - * @param ex the exception to copy - */ - BufferUnderflowException(const lang::Exception& ex); - - /** - * Copy Constructor - * - * @param ex the exception to copy, which is an instance of this type - */ - BufferUnderflowException(const BufferUnderflowException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - BufferUnderflowException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - BufferUnderflowException(const std::exception* cause); - - /** - * Constructor - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - BufferUnderflowException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - */ - virtual BufferUnderflowException* clone() const - { - return new BufferUnderflowException(*this); - } - - virtual ~BufferUnderflowException() throw(); - }; - -} // namespace nio -} // namespace decaf - -#endif /*_DECAF_NIO_BUFFERUNDERFLOWEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/nio/ByteBuffer.cpp b/activemq-cpp/src/main/decaf/nio/ByteBuffer.cpp index d315c0ec2..f45a9cc73 100644 --- a/activemq-cpp/src/main/decaf/nio/ByteBuffer.cpp +++ b/activemq-cpp/src/main/decaf/nio/ByteBuffer.cpp @@ -22,13 +22,16 @@ #include "decaf/lang/Integer.h" #include "decaf/lang/Long.h" #include "decaf/lang/Short.h" +#include +#include +#include using namespace std; using namespace decaf; using namespace decaf::nio; using namespace decaf::internal::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; //////////////////////////////////////////////////////////////////////////////// ByteBuffer::ByteBuffer(int capacity) @@ -43,8 +46,16 @@ ByteBuffer* ByteBuffer::allocate(int capacity) { return BufferFactory::createByteBuffer(capacity); } - DECAF_CATCH_RETHROW(IllegalArgumentException) - DECAF_CATCHALL_THROW(IllegalArgumentException) + catch (std::invalid_argument&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -57,7 +68,7 @@ ByteBuffer* ByteBuffer::wrap(unsigned char* buffer, { if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ByteBuffer::wrap - Passed Buffer is Null."); @@ -65,18 +76,38 @@ ByteBuffer* ByteBuffer::wrap(unsigned char* buffer, if (size < 0 || offset < 0 || length < 0 || offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Invalid array access parameters passed."); } return BufferFactory::createByteBuffer(buffer, size, offset, length); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -86,7 +117,7 @@ ByteBuffer* ByteBuffer::wrap(std::vector& buffer) { if (buffer.empty()) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ByteBuffer::wrap - Passed Buffer is Empty."); @@ -97,9 +128,31 @@ ByteBuffer* ByteBuffer::wrap(std::vector& buffer) 0, (int)buffer.size()); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -134,7 +187,7 @@ ByteBuffer& ByteBuffer::get(unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ByteBuffer::get - Passed Buffer is Null."); @@ -142,9 +195,9 @@ ByteBuffer& ByteBuffer::get(unsigned char* buffer, if (size < 0 || offset < 0 || length < 0 || offset + length > size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > this->remaining()) @@ -164,8 +217,6 @@ ByteBuffer& ByteBuffer::get(unsigned char* buffer, return *this; } DECAF_CATCH_RETHROW(BufferUnderflowException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferUnderflowException) DECAF_CATCHALL_THROW(BufferUnderflowException) } @@ -177,9 +228,9 @@ ByteBuffer& ByteBuffer::put(ByteBuffer& src) { if (this == &src) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "ByteBuffer::put - Can't put Self"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ByteBuffer::put - Can't put Self"); } if (this->isReadOnly()) @@ -206,8 +257,10 @@ ByteBuffer& ByteBuffer::put(ByteBuffer& src) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IllegalArgumentException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -235,7 +288,7 @@ ByteBuffer& ByteBuffer::put(const unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ByteBuffer::put - Passed Buffer is Null."); @@ -243,9 +296,9 @@ ByteBuffer& ByteBuffer::put(const unsigned char* buffer, if (size < 0 || offset < 0 || length < 0 || offset + length > size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > this->remaining()) @@ -265,8 +318,10 @@ ByteBuffer& ByteBuffer::put(const unsigned char* buffer, return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(NullPointerException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -284,7 +339,10 @@ ByteBuffer& ByteBuffer::put(std::vector& buffer) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } diff --git a/activemq-cpp/src/main/decaf/nio/ByteBuffer.h b/activemq-cpp/src/main/decaf/nio/ByteBuffer.h index cec877b41..e6ab4e1ea 100644 --- a/activemq-cpp/src/main/decaf/nio/ByteBuffer.h +++ b/activemq-cpp/src/main/decaf/nio/ByteBuffer.h @@ -18,13 +18,12 @@ #ifndef _DECAF_NIO_BYTEBUFFER_H_ #define _DECAF_NIO_BYTEBUFFER_H_ +#include #include -#include -#include #include #include -#include #include +#include namespace decaf { @@ -112,7 +111,7 @@ namespace nio * @param capacity * The size of the array, this is the limit we read and write to. * - * @throws IllegalArgumentException if capacity is negative. + * @throws std::invalid_argument if capacity is negative. */ ByteBuffer(int capacity); @@ -168,11 +167,11 @@ namespace nio * * @return a reference to this Buffer. * - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. * @throws BufferUnderflowException if there are fewer than length bytes * remaining in this buffer. - * @throws NullPointerException if the passed buffer is null. + * @throws std::logic_error if the passed buffer is null. */ ByteBuffer& get(unsigned char* buffer, int size, int offset, int length); @@ -194,7 +193,7 @@ namespace nio * * @throws BufferOverflowException if there is insufficient space in * this buffer for the remaining bytes in the source buffer - * @throws IllegalArgumentException if the source buffer is this buffer + * @throws std::invalid_argument if the source buffer is this buffer * @throws ReadOnlyBufferException if this buffer is read-only */ ByteBuffer& put(ByteBuffer& src); @@ -224,8 +223,8 @@ namespace nio * @throws BufferOverflowException if there is insufficient space in * this buffer. * @throws ReadOnlyBufferException if this buffer is read-only. - * @throws NullPointerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the passed buffer is null. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ ByteBuffer& put(const unsigned char* buffer, @@ -270,7 +269,7 @@ namespace nio * * @throws ReadOnlyBufferException if this buffer is backed by an array * but is read-only - * @throws UnsupportedOperationException if this buffer is not backed by + * @throws std::logic_error if this buffer is not backed by * an accessible array */ virtual unsigned char* array() = 0; @@ -290,7 +289,7 @@ namespace nio * * @throws ReadOnlyBufferException if this buffer is backed by an array * but is read-only. - * @throws UnsupportedOperationException if this buffer is not backed by + * @throws std::logic_error if this buffer is not backed by * an accessible array. */ virtual int arrayOffset() const = 0; @@ -485,7 +484,7 @@ namespace nio * * @return the byte that is located at the given index. * - * @throws IndexOutOfBoundsException if index is not smaller than the + * @throws std::out_of_range if index is not smaller than the * buffer's limit, or index is negative. */ virtual unsigned char get(int index) const = 0; @@ -509,7 +508,7 @@ namespace nio * * @return the char at the given index in the buffer * - * @throws IndexOutOfBoundsException if index is not smaller than the + * @throws std::out_of_range if index is not smaller than the * buffer's limit, or index is negative. */ virtual char getChar(int index) const = 0; @@ -533,7 +532,7 @@ namespace nio * * @return the double at the given index in the buffer. * - * @throws IndexOutOfBoundsException if index is not smaller than the + * @throws std::out_of_range if index is not smaller than the * buffer's limit, or index is negative. */ virtual double getDouble(int index) const = 0; @@ -557,7 +556,7 @@ namespace nio * * @return the float at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is * negative. */ @@ -582,7 +581,7 @@ namespace nio * * @return the long long at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is * negative. */ @@ -607,7 +606,7 @@ namespace nio * * @return the int at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is * negative. */ @@ -632,7 +631,7 @@ namespace nio * * @return the short at the given index in the buffer. * - * @throws IndexOutOfBoundsException if there are not enough bytes + * @throws std::out_of_range if there are not enough bytes * remaining to fill the requested Data Type, or index is * negative. */ @@ -660,7 +659,7 @@ namespace nio * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the buffer's + * @throw std::out_of_range if index greater than the buffer's * limit minus the size of the type being written, or index is negative. * @throw ReadOnlyBufferException if this buffer is read-only. */ @@ -692,7 +691,7 @@ namespace nio * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the buffer's + * @throw std::out_of_range if index greater than the buffer's * limit minus the size of the type being written, or index is negative. * @throw ReadOnlyBufferException if this buffer is read-only */ @@ -724,7 +723,7 @@ namespace nio * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the buffer's + * @throw std::out_of_range if index greater than the buffer's * limit minus the size of the type being written, or index is negative. * @throw ReadOnlyBufferException if this buffer is read-only. */ @@ -756,7 +755,7 @@ namespace nio * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the buffer's + * @throw std::out_of_range if index greater than the buffer's * limit minus the size of the type being written, or index is negative. * @throw ReadOnlyBufferException if this buffer is read-only. */ @@ -788,7 +787,7 @@ namespace nio * * @return a reference to this buffer. * - * @throw IndexOutOfBoundsException if index greater than the buffer's + * @throw std::out_of_range if index greater than the buffer's * limit minus the size of the type being written, or index is negative. * @throw ReadOnlyBufferException if this buffer is read-only. */ @@ -820,7 +819,7 @@ namespace nio * * @return a reference to this buffer * - * @throw IndexOutOfBoundsException if index greater than the buffer's + * @throw std::out_of_range if index greater than the buffer's * limit minus the size of the type being written, or index is negative. * @throw ReadOnlyBufferException if this buffer is read-only */ @@ -852,7 +851,7 @@ namespace nio * * @return a reference to this buffer * - * @throw IndexOutOfBoundsException if index greater than the buffer's + * @throw std::out_of_range if index greater than the buffer's * limit minus the size of the type being written, or index is negative. * @throw ReadOnlyBufferException if this buffer is read-only. */ @@ -907,7 +906,7 @@ namespace nio * * @return a newly allocated ByteBuffer which the caller owns. * - * @throws IllegalArgumentException if capacity is negative. + * @throws std::invalid_argument if capacity is negative. */ static ByteBuffer* allocate(int capacity); @@ -932,8 +931,8 @@ namespace nio * * @return a new ByteBuffer that is backed by buffer, caller owns. * - * @throws NullPointerException if the array passed in is NULL. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the array passed in is NULL. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ static ByteBuffer* wrap(unsigned char* array, diff --git a/activemq-cpp/src/main/decaf/nio/CharBuffer.cpp b/activemq-cpp/src/main/decaf/nio/CharBuffer.cpp index e400de0a9..2cf8ed597 100644 --- a/activemq-cpp/src/main/decaf/nio/CharBuffer.cpp +++ b/activemq-cpp/src/main/decaf/nio/CharBuffer.cpp @@ -17,16 +17,19 @@ #include "CharBuffer.h" #include "decaf/internal/nio/BufferFactory.h" +#include #include #include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal::nio; +using activemq::exceptions::BufferUnderflowException; //////////////////////////////////////////////////////////////////////////////// CharBuffer::CharBuffer(int capacity) @@ -41,9 +44,9 @@ CharBuffer* CharBuffer::allocate(int capacity) { if (capacity < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Capacity given was negative."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Capacity given was negative."); } return BufferFactory::createCharBuffer(capacity); @@ -59,7 +62,7 @@ CharBuffer* CharBuffer::wrap(char* buffer, int size, int offset, int length) { if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "CharBuffer::wrap - Passed Buffer is Null."); @@ -67,9 +70,31 @@ CharBuffer* CharBuffer::wrap(char* buffer, int size, int offset, int length) return BufferFactory::createCharBuffer(buffer, size, offset, length); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -79,7 +104,7 @@ CharBuffer* CharBuffer::wrap(std::vector& buffer) { if (buffer.empty()) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "CharBuffer::wrap - Passed Buffer is Empty."); @@ -90,9 +115,31 @@ CharBuffer* CharBuffer::wrap(std::vector& buffer) 0, (int)buffer.size()); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -118,7 +165,10 @@ CharBuffer& CharBuffer::append(char value) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -136,7 +186,10 @@ CharBuffer& CharBuffer::append(const CharSequence* value) return this->put("null"); } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -156,11 +209,17 @@ CharBuffer& CharBuffer::append(const CharSequence* value, int start, int end) return this->put("null", 4, start, end - start); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) - DECAF_CATCHALL_THROW(BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP(BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -170,16 +229,29 @@ char CharBuffer::charAt(int index) const { if (index < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Index given was negative."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index given was negative."); } return this->get(index); } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -210,7 +282,7 @@ CharBuffer& CharBuffer::get(char* buffer, int size, int offset, int length) if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "CharBuffer::get - Passed Buffer is Null"); @@ -219,18 +291,21 @@ CharBuffer& CharBuffer::get(char* buffer, int size, int offset, int length) if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > remaining()) { throw BufferUnderflowException( - __FILE__, - __LINE__, - "CharBuffer::get - Not enough data to fill length = %d", - length); + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + std::string( + "CharBuffer::get - Not enough data to fill length " + "= ") + + std::to_string(length))); } for (int ix = 0; ix < length; ++ix) @@ -240,8 +315,6 @@ CharBuffer& CharBuffer::get(char* buffer, int size, int offset, int length) return *this; } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCH_RETHROW(BufferUnderflowException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferUnderflowException) DECAF_CATCHALL_THROW(BufferUnderflowException) @@ -254,9 +327,9 @@ CharBuffer& CharBuffer::put(CharBuffer& src) { if (this == &src) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "CharBuffer::put - Can't put Self"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "CharBuffer::put - Can't put Self"); } if (this->isReadOnly()) @@ -283,8 +356,10 @@ CharBuffer& CharBuffer::put(CharBuffer& src) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IllegalArgumentException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -309,7 +384,7 @@ CharBuffer& CharBuffer::put(const char* buffer, int size, int offset, int length if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "CharBuffer::put - Passed Buffer is Null."); @@ -318,9 +393,9 @@ CharBuffer& CharBuffer::put(const char* buffer, int size, int offset, int length if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > this->remaining()) @@ -340,9 +415,10 @@ CharBuffer& CharBuffer::put(const char* buffer, int size, int offset, int length return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -360,7 +436,10 @@ CharBuffer& CharBuffer::put(std::vector& buffer) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -372,33 +451,37 @@ CharBuffer& CharBuffer::put(std::string& src, int start, int end) { if ((start > end) || ((int)src.size() < (end - start))) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "CharBuffer::put - invalid start " - "and end pos; start = %d, end = %d", - start, - end); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "CharBuffer::put - invalid start " + "and end pos; start = " + + std::to_string(start) + ", end = " + std::to_string(end)); } if (start > (int)src.size() || end > (int)src.size()) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "CharBuffer::put - invalid start " - "and end pos; start = %d, end = %d", - start, - end); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "CharBuffer::put - invalid start " + "and end pos; start = " + + std::to_string(start) + ", end = " + std::to_string(end)); } this->put(src.substr(start, end - start)); return *this; } - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) - DECAF_CATCHALL_THROW(BufferOverflowException) + DECAF_CATCHALL_THROW_AFTER_STL_OUT_OF_RANGE_MAP(BufferOverflowException) } //////////////////////////////////////////////////////////////////////////////// @@ -414,7 +497,10 @@ CharBuffer& CharBuffer::put(const std::string& src) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -426,15 +512,14 @@ int CharBuffer::read(CharBuffer* target) { if (target == this) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CharBuffer::read - Cannot read to self"); } if (target == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "CharBuffer::read - Null CharBuffer Passed"); @@ -453,11 +538,40 @@ int CharBuffer::read(CharBuffer* target) return result; } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IllegalArgumentException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, IllegalArgumentException) - DECAF_CATCHALL_THROW(IllegalArgumentException) + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::BufferUnderflowException&) + { + throw; + } + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (decaf::nio::BufferOverflowException&) + { + throw; + } + catch (decaf::nio::ReadOnlyBufferException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::InvalidArgumentException(ex.getMessage()); + } + catch (...) + { + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/decaf/nio/CharBuffer.h b/activemq-cpp/src/main/decaf/nio/CharBuffer.h index 896db37db..c8f5647c4 100644 --- a/activemq-cpp/src/main/decaf/nio/CharBuffer.h +++ b/activemq-cpp/src/main/decaf/nio/CharBuffer.h @@ -18,15 +18,14 @@ #ifndef _DECAF_NIO_CHARBUFFER_H_ #define _DECAF_NIO_CHARBUFFER_H_ +#include #include #include #include -#include -#include #include #include -#include #include +#include namespace decaf { @@ -136,7 +135,7 @@ namespace nio * * @throws BufferOverflowException if there is no more space * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws IndexOutOfBoundsException if start > end, or > length of + * @throws std::out_of_range if start > end, or > length of * sequence. */ CharBuffer& append(const lang::CharSequence* value, int start, int end); @@ -154,7 +153,7 @@ namespace nio * @return the array that backs this Buffer. * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual char* array() = 0; @@ -169,7 +168,7 @@ namespace nio * @return The offset into the backing array where index zero starts. * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual int arrayOffset() = 0; @@ -203,7 +202,7 @@ namespace nio * * @return The character at index position() + index. * - * @throws IndexOutOfBoundsException if the index + the current position + * @throws std::out_of_range if the index + the current position * exceeds the size of the buffer or the index is negative. */ char charAt(int index) const; @@ -263,7 +262,7 @@ namespace nio * * @return the char that is located at the given index. * - * @throws IndexOutOfBoundsException if index is not smaller than the + * @throws std::out_of_range if index is not smaller than the * buffer's limit or is negative. */ virtual char get(int index) const = 0; @@ -312,8 +311,8 @@ namespace nio * * @throws BufferUnderflowException if there are fewer than length chars * remaining in this buffer - * @throws NullPointerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the passed buffer is null. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ CharBuffer& get(char* buffer, int size, int offset, int length); @@ -357,7 +356,7 @@ namespace nio * * @throws BufferOverflowException if there is insufficient space in * this buffer for the remaining chars in the source buffer. - * @throws IllegalArgumentException if the source buffer is this buffer. + * @throws std::invalid_argument if the source buffer is this buffer. * @throws ReadOnlyBufferException if this buffer is read-only. */ CharBuffer& put(CharBuffer& src); @@ -387,8 +386,8 @@ namespace nio * @throws BufferOverflowException if there is insufficient space in * this buffer * @throws ReadOnlyBufferException if this buffer is read-only - * @throws NullPointerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the passed buffer is null. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ CharBuffer& put(const char* buffer, int size, int offset, int length); @@ -434,7 +433,7 @@ namespace nio * * @return a reference to this buffer. * - * @throws IndexOutOfBoundsException if index greater than the buffer's + * @throws std::out_of_range if index greater than the buffer's * limit minus the size of the type being written, or index is negative. * @throws ReadOnlyBufferException if this buffer is read-only. */ @@ -466,7 +465,7 @@ namespace nio * * @throws BufferOverflowException if this buffer's current position is * not - * @throws IndexOutOfBoundsException if index greater than the buffer's + * @throws std::out_of_range if index greater than the buffer's * limit minus the size of the type being written. * @throws ReadOnlyBufferException if this buffer is read-only */ @@ -502,8 +501,8 @@ namespace nio * @return The number of characters added to the buffer, or string::npos * if this source of characters is at its end * - * @throws NullPointerException if target is Null. - * @throws IllegalArgumentException if target is this CharBuffer. + * @throws std::logic_error if target is Null. + * @throws std::invalid_argument if target is this CharBuffer. * @throws ReadOnlyBufferException if this buffer is in read-only mode. */ virtual int read(CharBuffer* target); @@ -530,7 +529,7 @@ namespace nio * * @return The new character buffer, caller owns. * - * @throws IndexOutOfBoundsException if the preconditions on start and + * @throws std::out_of_range if the preconditions on start and * end fail. */ virtual lang::CharSequence* subSequence(int start, int end) const = 0; @@ -585,7 +584,7 @@ namespace nio * * @return the CharBuffer that was allocated, caller owns. * - * @throws IndexOutOfBoundsException if capacity is negative. + * @throws std::out_of_range if capacity is negative. */ static CharBuffer* allocate(int capacity); @@ -610,8 +609,8 @@ namespace nio * * @return a new CharBuffer that is backed by buffer, caller owns. * - * @throws NullPointerException if the array pointer is Null. - * @throws IndexOutOfBoundsException if capacity is negative. + * @throws std::logic_error if the array pointer is Null. + * @throws std::out_of_range if capacity is negative. */ static CharBuffer* wrap(char* array, int size, int offset, int length); @@ -653,8 +652,8 @@ namespace nio * * @return a ReadOnly CharBuffer, caller owns the returned pointer. * - * @throws NullPointerException if csq is null. - * @throws IndexOutOfBoundsException if the preconditions on start and + * @throws std::logic_error if csq is null. + * @throws std::out_of_range if the preconditions on start and * end fail */ // TODO @@ -675,7 +674,7 @@ namespace nio * * @return the newly created CharBuffer, caller owns. * - * @throws NullPointerException if csq is null. + * @throws std::logic_error if csq is null. */ // TODO // static CharBuffer* wrap( lang::CharSequence* csq ); diff --git a/activemq-cpp/src/main/decaf/nio/DoubleBuffer.cpp b/activemq-cpp/src/main/decaf/nio/DoubleBuffer.cpp index c7ee380ee..b9fad8052 100644 --- a/activemq-cpp/src/main/decaf/nio/DoubleBuffer.cpp +++ b/activemq-cpp/src/main/decaf/nio/DoubleBuffer.cpp @@ -18,15 +18,18 @@ #include "DoubleBuffer.h" #include "decaf/internal/nio/BufferFactory.h" +#include #include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::nio; using namespace decaf::internal::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; //////////////////////////////////////////////////////////////////////////////// DoubleBuffer::DoubleBuffer(int capacity) @@ -41,8 +44,16 @@ DoubleBuffer* DoubleBuffer::allocate(int capacity) { return BufferFactory::createDoubleBuffer(capacity); } - DECAF_CATCH_RETHROW(IllegalArgumentException) - DECAF_CATCHALL_THROW(IllegalArgumentException) + catch (std::invalid_argument&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -55,7 +66,7 @@ DoubleBuffer* DoubleBuffer::wrap(double* buffer, { if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "DoubleBuffer::wrap - Passed Buffer is Null."); @@ -63,10 +74,31 @@ DoubleBuffer* DoubleBuffer::wrap(double* buffer, return BufferFactory::createDoubleBuffer(buffer, size, offset, length); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -76,7 +108,7 @@ DoubleBuffer* DoubleBuffer::wrap(std::vector& buffer) { if (buffer.empty()) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "DoubleBuffer::wrap - Passed Buffer is Empty."); @@ -87,9 +119,31 @@ DoubleBuffer* DoubleBuffer::wrap(std::vector& buffer) 0, (int)buffer.size()); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -132,7 +186,7 @@ DoubleBuffer& DoubleBuffer::get(double* buffer, int size, int offset, int length if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "DoubleBuffer::get - Passed Buffer is Null"); @@ -141,18 +195,20 @@ DoubleBuffer& DoubleBuffer::get(double* buffer, int size, int offset, int length if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > remaining()) { throw BufferUnderflowException( - __FILE__, - __LINE__, - "DoubleBuffer::get - Not enough data to fill length = %d", - length); + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + std::string("DoubleBuffer::get - Not enough data to fill " + "length = ") + + std::to_string(length))); } for (int ix = 0; ix < length; ++ix) @@ -163,8 +219,6 @@ DoubleBuffer& DoubleBuffer::get(double* buffer, int size, int offset, int length return *this; } DECAF_CATCH_RETHROW(BufferUnderflowException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferUnderflowException) DECAF_CATCHALL_THROW(BufferUnderflowException) } @@ -176,9 +230,8 @@ DoubleBuffer& DoubleBuffer::put(DoubleBuffer& src) { if (this == &src) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "DoubleBuffer::put - Can't put Self"); } @@ -206,8 +259,10 @@ DoubleBuffer& DoubleBuffer::put(DoubleBuffer& src) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IllegalArgumentException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -235,7 +290,7 @@ DoubleBuffer& DoubleBuffer::put(const double* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "DoubleBuffer::put - Passed Buffer is Null."); @@ -244,9 +299,9 @@ DoubleBuffer& DoubleBuffer::put(const double* buffer, if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > this->remaining()) @@ -266,9 +321,10 @@ DoubleBuffer& DoubleBuffer::put(const double* buffer, return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -286,7 +342,10 @@ DoubleBuffer& DoubleBuffer::put(std::vector& buffer) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } diff --git a/activemq-cpp/src/main/decaf/nio/DoubleBuffer.h b/activemq-cpp/src/main/decaf/nio/DoubleBuffer.h index 416941666..dfe27bf9f 100644 --- a/activemq-cpp/src/main/decaf/nio/DoubleBuffer.h +++ b/activemq-cpp/src/main/decaf/nio/DoubleBuffer.h @@ -18,13 +18,12 @@ #ifndef _DECAF_NIO_DOUBLEBUFFER_H_ #define _DECAF_NIO_DOUBLEBUFFER_H_ +#include #include -#include -#include #include #include -#include #include +#include namespace decaf { @@ -90,7 +89,7 @@ namespace nio * @return the array that backs this Buffer. * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual double* array() = 0; @@ -105,7 +104,7 @@ namespace nio * @return The offset into the backing array where index zero starts. * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual int arrayOffset() = 0; @@ -185,7 +184,7 @@ namespace nio * * @return the double that is located at the given index. * - * @throws IndexOutOfBoundsException if index is not smaller than the + * @throws std::out_of_range if index is not smaller than the * buffer's limit */ virtual double get(int index) const = 0; @@ -234,8 +233,8 @@ namespace nio * * @throws BufferUnderflowException if there are fewer than length * doubles remaining in this buffer - * @throws NullPointerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the passed buffer is null. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ DoubleBuffer& get(double* buffer, int size, int offset, int length); @@ -270,7 +269,7 @@ namespace nio * * @throws BufferOverflowException if there is insufficient space in * this buffer for the remaining doubles in the source buffer - * @throws IllegalArgumentException if the source buffer is this buffer. + * @throws std::invalid_argument if the source buffer is this buffer. * @throws ReadOnlyBufferException if this buffer is read-only. */ DoubleBuffer& put(DoubleBuffer& src); @@ -300,8 +299,8 @@ namespace nio * @throws BufferOverflowException if there is insufficient space in * this buffer * @throws ReadOnlyBufferException if this buffer is read-only - * @throws NullPointerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the passed buffer is null. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ DoubleBuffer& put(const double* buffer, @@ -350,7 +349,7 @@ namespace nio * * @return a reference to this buffer * - * @throws IndexOutOfBoundsException if index greater than the buffer's + * @throws std::out_of_range if index greater than the buffer's * limit minus the size of the type being written, or the index is * negative. * @throws ReadOnlyBufferException if this buffer is read-only. @@ -407,7 +406,7 @@ namespace nio * * @return the DoubleBuffer that was allocated, caller owns. * - * @throws IllegalArgumentException is the capacity value is negative. + * @throws std::invalid_argument is the capacity value is negative. */ static DoubleBuffer* allocate(int capacity); @@ -432,8 +431,8 @@ namespace nio * * @return a new DoubleBuffer that is backed by buffer, caller owns. * - * @throws NullPointerException if the array pointer is NULL. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the array pointer is NULL. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ static DoubleBuffer* wrap(double* array, diff --git a/activemq-cpp/src/main/decaf/nio/FloatBuffer.cpp b/activemq-cpp/src/main/decaf/nio/FloatBuffer.cpp index bf89793d5..a7aea2072 100644 --- a/activemq-cpp/src/main/decaf/nio/FloatBuffer.cpp +++ b/activemq-cpp/src/main/decaf/nio/FloatBuffer.cpp @@ -18,15 +18,18 @@ #include "FloatBuffer.h" #include "decaf/internal/nio/BufferFactory.h" +#include #include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::nio; using namespace decaf::internal::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; //////////////////////////////////////////////////////////////////////////////// FloatBuffer::FloatBuffer(int capacity) @@ -52,7 +55,7 @@ FloatBuffer* FloatBuffer::wrap(float* buffer, int size, int offset, int length) { if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "FloatBuffer::wrap - Passed Buffer is Null."); @@ -60,9 +63,31 @@ FloatBuffer* FloatBuffer::wrap(float* buffer, int size, int offset, int length) return BufferFactory::createFloatBuffer(buffer, size, offset, length); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -72,7 +97,7 @@ FloatBuffer* FloatBuffer::wrap(std::vector& buffer) { if (buffer.empty()) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "FloatBuffer::wrap - Passed Buffer is Empty."); @@ -83,9 +108,31 @@ FloatBuffer* FloatBuffer::wrap(std::vector& buffer) 0, (int)buffer.size()); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -128,7 +175,7 @@ FloatBuffer& FloatBuffer::get(float* buffer, int size, int offset, int length) if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "FloatBuffer::get - Passed Buffer is Null"); @@ -137,18 +184,21 @@ FloatBuffer& FloatBuffer::get(float* buffer, int size, int offset, int length) if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > remaining()) { throw BufferUnderflowException( - __FILE__, - __LINE__, - "FloatBuffer::get - Not enough data to fill length = %d", - length); + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + std::string( + "FloatBuffer::get - Not enough data to fill length " + "= ") + + std::to_string(length))); } for (int ix = 0; ix < length; ++ix) @@ -159,8 +209,6 @@ FloatBuffer& FloatBuffer::get(float* buffer, int size, int offset, int length) return *this; } DECAF_CATCH_RETHROW(BufferUnderflowException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferUnderflowException) DECAF_CATCHALL_THROW(BufferUnderflowException) } @@ -172,9 +220,9 @@ FloatBuffer& FloatBuffer::put(FloatBuffer& src) { if (this == &src) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "FloatBuffer::put - Can't put Self"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "FloatBuffer::put - Can't put Self"); } if (this->isReadOnly()) @@ -201,8 +249,10 @@ FloatBuffer& FloatBuffer::put(FloatBuffer& src) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IllegalArgumentException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -230,7 +280,7 @@ FloatBuffer& FloatBuffer::put(const float* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "FloatBuffer::put - Passed Buffer is Null."); @@ -239,9 +289,9 @@ FloatBuffer& FloatBuffer::put(const float* buffer, if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > this->remaining()) @@ -261,9 +311,10 @@ FloatBuffer& FloatBuffer::put(const float* buffer, return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -281,7 +332,10 @@ FloatBuffer& FloatBuffer::put(std::vector& buffer) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } diff --git a/activemq-cpp/src/main/decaf/nio/FloatBuffer.h b/activemq-cpp/src/main/decaf/nio/FloatBuffer.h index f915d94c7..58e36fff1 100644 --- a/activemq-cpp/src/main/decaf/nio/FloatBuffer.h +++ b/activemq-cpp/src/main/decaf/nio/FloatBuffer.h @@ -18,13 +18,12 @@ #ifndef _DECAF_NIO_FLOATBUFFER_H_ #define _DECAF_NIO_FLOATBUFFER_H_ +#include #include -#include -#include #include #include -#include #include +#include namespace decaf { @@ -87,7 +86,7 @@ namespace nio * @return the array that backs this Buffer. * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual float* array() = 0; @@ -102,7 +101,7 @@ namespace nio * @return The offset into the backing array where index zero starts. * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual int arrayOffset() = 0; @@ -182,7 +181,7 @@ namespace nio * * @return the float that is located at the given index * - * @throws IndexOutOfBoundsException if index is not smaller than the + * @throws std::out_of_range if index is not smaller than the * buffer's limit */ virtual float get(int index) const = 0; @@ -231,8 +230,8 @@ namespace nio * * @throws BufferUnderflowException if there are fewer than length * floats remaining in this buffer - * @throws NullPointerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the passed buffer is null. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ FloatBuffer& get(float* buffer, int size, int offset, int length); @@ -267,7 +266,7 @@ namespace nio * * @throws BufferOverflowException if there is insufficient space in * this buffer for the remaining floats in the source buffer - * @throws IllegalArgumentException if the source buffer is this buffer. + * @throws std::invalid_argument if the source buffer is this buffer. * @throws ReadOnlyBufferException if this buffer is read-only. */ FloatBuffer& put(FloatBuffer& src); @@ -297,8 +296,8 @@ namespace nio * @throws BufferOverflowException if there is insufficient space in * this buffer * @throws ReadOnlyBufferException if this buffer is read-only - * @throws NullPointerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the passed buffer is null. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ FloatBuffer& put(const float* buffer, int size, int offset, int length); @@ -344,7 +343,7 @@ namespace nio * * @return a reference to this buffer. * - * @throws IndexOutOfBoundsException if index greater than the buffer's + * @throws std::out_of_range if index greater than the buffer's * limit minus the size of the type being written, or index is negative. * @throws ReadOnlyBufferException if this buffer is read-only. */ @@ -423,8 +422,8 @@ namespace nio * * @return a new FloatBuffer that is backed by buffer, caller owns. * - * @throws NullPointerException if the array pointer is NULL. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the array pointer is NULL. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ static FloatBuffer* wrap(float* array, int size, int offset, int length); diff --git a/activemq-cpp/src/main/decaf/nio/IntBuffer.cpp b/activemq-cpp/src/main/decaf/nio/IntBuffer.cpp index 6053b10b3..d228373b0 100644 --- a/activemq-cpp/src/main/decaf/nio/IntBuffer.cpp +++ b/activemq-cpp/src/main/decaf/nio/IntBuffer.cpp @@ -18,15 +18,18 @@ #include "IntBuffer.h" #include "decaf/internal/nio/BufferFactory.h" +#include #include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal::nio; +using activemq::exceptions::BufferUnderflowException; //////////////////////////////////////////////////////////////////////////////// IntBuffer::IntBuffer(int capacity) @@ -52,7 +55,7 @@ IntBuffer* IntBuffer::wrap(int* buffer, int size, int offset, int length) { if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "IntBuffer::wrap - Passed Buffer is Null."); @@ -60,9 +63,31 @@ IntBuffer* IntBuffer::wrap(int* buffer, int size, int offset, int length) return BufferFactory::createIntBuffer(buffer, size, offset, length); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -72,7 +97,7 @@ IntBuffer* IntBuffer::wrap(std::vector& buffer) { if (buffer.empty()) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "IntBuffer::wrap - Passed Buffer is Empty."); @@ -83,9 +108,31 @@ IntBuffer* IntBuffer::wrap(std::vector& buffer) 0, (int)buffer.size()); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -128,7 +175,7 @@ IntBuffer& IntBuffer::get(int* buffer, int size, int offset, int length) if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "IntBuffer::get - Passed Buffer is Null"); @@ -137,18 +184,21 @@ IntBuffer& IntBuffer::get(int* buffer, int size, int offset, int length) if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > remaining()) { throw BufferUnderflowException( - __FILE__, - __LINE__, - "IntBuffer::get - Not enough data to fill length = %d", - length); + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + std::string( + "IntBuffer::get - Not enough data to fill length " + "= ") + + std::to_string(length))); } for (int ix = 0; ix < length; ++ix) @@ -159,8 +209,6 @@ IntBuffer& IntBuffer::get(int* buffer, int size, int offset, int length) return *this; } DECAF_CATCH_RETHROW(BufferUnderflowException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferUnderflowException) DECAF_CATCHALL_THROW(BufferUnderflowException) } @@ -172,9 +220,9 @@ IntBuffer& IntBuffer::put(IntBuffer& src) { if (this == &src) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "IntBuffer::put - Can't put Self"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "IntBuffer::put - Can't put Self"); } if (this->isReadOnly()) @@ -201,8 +249,10 @@ IntBuffer& IntBuffer::put(IntBuffer& src) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IllegalArgumentException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -227,7 +277,7 @@ IntBuffer& IntBuffer::put(const int* buffer, int size, int offset, int length) if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "IntBuffer::put - Passed Buffer is Null."); @@ -236,9 +286,9 @@ IntBuffer& IntBuffer::put(const int* buffer, int size, int offset, int length) if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > this->remaining()) @@ -258,9 +308,10 @@ IntBuffer& IntBuffer::put(const int* buffer, int size, int offset, int length) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -278,7 +329,10 @@ IntBuffer& IntBuffer::put(std::vector& buffer) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } diff --git a/activemq-cpp/src/main/decaf/nio/IntBuffer.h b/activemq-cpp/src/main/decaf/nio/IntBuffer.h index b0ae7196e..34c684d3e 100644 --- a/activemq-cpp/src/main/decaf/nio/IntBuffer.h +++ b/activemq-cpp/src/main/decaf/nio/IntBuffer.h @@ -18,13 +18,12 @@ #ifndef _DECAF_NIO_INTBUFFER_H_ #define _DECAF_NIO_INTBUFFER_H_ +#include #include -#include -#include #include #include -#include #include +#include namespace decaf { @@ -87,7 +86,7 @@ namespace nio * @return the array that backs this Buffer. * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual int* array() = 0; @@ -102,7 +101,7 @@ namespace nio * @return The offset into the backing array where index zero starts. * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual int arrayOffset() = 0; @@ -182,7 +181,7 @@ namespace nio * * @return the int that is located at the given index. * - * @throws IndexOutOfBoundsException if index is not smaller than the + * @throws std::out_of_range if index is not smaller than the * buffer's limit, or index is negative. */ virtual int get(int index) const = 0; @@ -231,8 +230,8 @@ namespace nio * * @throws BufferUnderflowException if there are fewer than length ints * remaining in this buffer. - * @throws NullPointerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the passed buffer is null. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ IntBuffer& get(int* buffer, int size, int offset, int length); @@ -267,7 +266,7 @@ namespace nio * * @throws BufferOverflowException if there is insufficient space in * this buffer for the remaining ints in the source buffer. - * @throws IllegalArgumentException if the source buffer is this buffer. + * @throws std::invalid_argument if the source buffer is this buffer. * @throws ReadOnlyBufferException if this buffer is read-only. */ IntBuffer& put(IntBuffer& src); @@ -297,8 +296,8 @@ namespace nio * @throws BufferOverflowException if there is insufficient space in * this buffer. * @throws ReadOnlyBufferException if this buffer is read-only. - * @throws NullPointerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the passed buffer is null. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ IntBuffer& put(const int* buffer, int size, int offset, int length); @@ -344,7 +343,7 @@ namespace nio * * @return a reference to this buffer. * - * @throws IndexOutOfBoundsException - If index greater than the + * @throws std::out_of_range - If index greater than the * buffer's limit minus the size of the type being written, or the index * is negative. * @throws ReadOnlyBufferException - If this buffer is read-only. @@ -424,8 +423,8 @@ namespace nio * * @return a new IntBuffer that is backed by buffer, caller owns. * - * @throws NullPointerException if the array pointer is NULL. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the array pointer is NULL. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ static IntBuffer* wrap(int* array, int size, int offset, int length); diff --git a/activemq-cpp/src/main/decaf/nio/InvalidMarkException.cpp b/activemq-cpp/src/main/decaf/nio/InvalidMarkException.cpp index 8c6daf81f..ec0a36ea5 100644 --- a/activemq-cpp/src/main/decaf/nio/InvalidMarkException.cpp +++ b/activemq-cpp/src/main/decaf/nio/InvalidMarkException.cpp @@ -17,69 +17,30 @@ #include "InvalidMarkException.h" -using namespace decaf; using namespace decaf::nio; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// InvalidMarkException::InvalidMarkException() - : lang::exceptions::IllegalStateException() + : std::logic_error("InvalidMarkException") { } //////////////////////////////////////////////////////////////////////////////// -InvalidMarkException::~InvalidMarkException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -InvalidMarkException::InvalidMarkException(const lang::Exception& ex) - : lang::exceptions::IllegalStateException() -{ - *(lang::Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -InvalidMarkException::InvalidMarkException(const InvalidMarkException& ex) - : lang::exceptions::IllegalStateException() +InvalidMarkException::InvalidMarkException(const std::string& message) + : std::logic_error(message) { - *(lang::Exception*)this = ex; } //////////////////////////////////////////////////////////////////////////////// -InvalidMarkException::InvalidMarkException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : lang::exceptions::IllegalStateException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -InvalidMarkException::InvalidMarkException(const std::exception* cause) - : lang::exceptions::IllegalStateException(cause) +InvalidMarkException::InvalidMarkException(const char* file, + int lineNumber, + const char* message) + : std::logic_error(std::string(file) + ":" + std::to_string(lineNumber) + + ": " + message) { } //////////////////////////////////////////////////////////////////////////////// -InvalidMarkException::InvalidMarkException(const char* file, - const int lineNumber, - const char* msg, - ...) - : lang::exceptions::IllegalStateException() +InvalidMarkException::~InvalidMarkException() throw() { - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); } diff --git a/activemq-cpp/src/main/decaf/nio/InvalidMarkException.h b/activemq-cpp/src/main/decaf/nio/InvalidMarkException.h index daefce65d..3a55e150c 100644 --- a/activemq-cpp/src/main/decaf/nio/InvalidMarkException.h +++ b/activemq-cpp/src/main/decaf/nio/InvalidMarkException.h @@ -18,92 +18,32 @@ #ifndef _DECAF_NIO_INVALIDMARKEXCEPTION_H_ #define _DECAF_NIO_INVALIDMARKEXCEPTION_H_ -#include #include +#include +#include + namespace decaf { namespace nio { - class DECAF_API InvalidMarkException - : public lang::exceptions::IllegalStateException + /** + * Thrown when a buffer mark is invalid or unset (idiomatically a + * logic_error). + * + * @since 1.0 + */ + class DECAF_API InvalidMarkException : public std::logic_error { public: - /** - * Default Constructor - */ InvalidMarkException(); - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose state data is to be copied into this - * Exception. - */ - InvalidMarkException(const lang::Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose state data is to be copied into this - * Exception. - */ - InvalidMarkException(const InvalidMarkException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - InvalidMarkException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); + explicit InvalidMarkException(const std::string& message); - /** - * Constructor - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - InvalidMarkException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ InvalidMarkException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return A new Exception instance that is a copy of this Exception. - */ - virtual InvalidMarkException* clone() const - { - return new InvalidMarkException(*this); - } + int lineNumber, + const char* message); virtual ~InvalidMarkException() throw(); }; diff --git a/activemq-cpp/src/main/decaf/nio/LongBuffer.cpp b/activemq-cpp/src/main/decaf/nio/LongBuffer.cpp index 91620cf14..a086cb0a2 100644 --- a/activemq-cpp/src/main/decaf/nio/LongBuffer.cpp +++ b/activemq-cpp/src/main/decaf/nio/LongBuffer.cpp @@ -18,15 +18,18 @@ #include "LongBuffer.h" #include "decaf/internal/nio/BufferFactory.h" +#include #include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal::nio; +using activemq::exceptions::BufferUnderflowException; //////////////////////////////////////////////////////////////////////////////// LongBuffer::LongBuffer(int capacity) @@ -52,7 +55,7 @@ LongBuffer* LongBuffer::wrap(long long* buffer, int size, int offset, int length { if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "LongBuffer::wrap - Passed Buffer is Null."); @@ -60,9 +63,31 @@ LongBuffer* LongBuffer::wrap(long long* buffer, int size, int offset, int length return BufferFactory::createLongBuffer(buffer, size, offset, length); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -72,7 +97,7 @@ LongBuffer* LongBuffer::wrap(std::vector& buffer) { if (buffer.empty()) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "LongBuffer::wrap - Passed Buffer is Empty."); @@ -83,9 +108,31 @@ LongBuffer* LongBuffer::wrap(std::vector& buffer) 0, (int)buffer.size()); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -128,7 +175,7 @@ LongBuffer& LongBuffer::get(long long* buffer, int size, int offset, int length) if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "LongBuffer::get - Passed Buffer is Null"); @@ -137,18 +184,21 @@ LongBuffer& LongBuffer::get(long long* buffer, int size, int offset, int length) if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > remaining()) { throw BufferUnderflowException( - __FILE__, - __LINE__, - "LongBuffer::get - Not enough data to fill length = %d", - length); + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + std::string( + "LongBuffer::get - Not enough data to fill length " + "= ") + + std::to_string(length))); } for (int ix = 0; ix < length; ++ix) @@ -159,8 +209,6 @@ LongBuffer& LongBuffer::get(long long* buffer, int size, int offset, int length) return *this; } DECAF_CATCH_RETHROW(BufferUnderflowException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferUnderflowException) DECAF_CATCHALL_THROW(BufferUnderflowException) } @@ -172,9 +220,9 @@ LongBuffer& LongBuffer::put(LongBuffer& src) { if (this == &src) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "LongBuffer::put - Can't put Self"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "LongBuffer::put - Can't put Self"); } if (this->isReadOnly()) @@ -201,8 +249,10 @@ LongBuffer& LongBuffer::put(LongBuffer& src) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IllegalArgumentException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -230,7 +280,7 @@ LongBuffer& LongBuffer::put(const long long* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "LongBuffer::put - Passed Buffer is Null."); @@ -239,9 +289,9 @@ LongBuffer& LongBuffer::put(const long long* buffer, if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > this->remaining()) @@ -261,9 +311,10 @@ LongBuffer& LongBuffer::put(const long long* buffer, return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -281,7 +332,10 @@ LongBuffer& LongBuffer::put(std::vector& buffer) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } diff --git a/activemq-cpp/src/main/decaf/nio/LongBuffer.h b/activemq-cpp/src/main/decaf/nio/LongBuffer.h index 2da1aa787..b63adc5fd 100644 --- a/activemq-cpp/src/main/decaf/nio/LongBuffer.h +++ b/activemq-cpp/src/main/decaf/nio/LongBuffer.h @@ -18,13 +18,12 @@ #ifndef _DECAF_NIO_LONGBUFFER_H_ #define _DECAF_NIO_LONGBUFFER_H_ +#include #include -#include -#include #include #include -#include #include +#include namespace decaf { @@ -90,7 +89,7 @@ namespace nio * @return the array that backs this Buffer. * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual long long* array() = 0; @@ -106,7 +105,7 @@ namespace nio * starts. * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual int arrayOffset() = 0; @@ -187,7 +186,7 @@ namespace nio * * @return the long long that is located at the given index. * - * @throws IndexOutOfBoundsException if index is not smaller than the + * @throws std::out_of_range if index is not smaller than the * buffer's limit, or index is negative. */ virtual long long get(int index) const = 0; @@ -237,7 +236,7 @@ namespace nio * @throws BufferUnderflowException if there are fewer than length long * longs remaining in this buffer * @throws NullPolong longerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ LongBuffer& get(long long* buffer, int size, int offset, int length); @@ -273,7 +272,7 @@ namespace nio * * @throws BufferOverflowException if there is insufficient space in * this buffer for the remaining long longs in the source buffer - * @throws IllegalArgumentException if the source buffer is this buffer + * @throws std::invalid_argument if the source buffer is this buffer * @throws ReadOnlyBufferException if this buffer is read-only */ LongBuffer& put(LongBuffer& src); @@ -305,7 +304,7 @@ namespace nio * this buffer * @throws ReadOnlyBufferException if this buffer is read-only * @throws NullPolong longerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ LongBuffer& put(const long long* buffer, @@ -355,7 +354,7 @@ namespace nio * * @return a reference to this buffer. * - * @throws IndexOutOfBoundsException if index greater than the buffer's + * @throws std::out_of_range if index greater than the buffer's * limit minus the size of the type being written. * @throws ReadOnlyBufferException if this buffer is read-only */ @@ -434,8 +433,8 @@ namespace nio * * @return a new LongBuffer that is backed by buffer, caller owns. * - * @throws NullPointerException if the array pointer is NULL. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the array pointer is NULL. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ static LongBuffer* wrap(long long* array, diff --git a/activemq-cpp/src/main/decaf/nio/ReadOnlyBufferException.cpp b/activemq-cpp/src/main/decaf/nio/ReadOnlyBufferException.cpp index f1ca68232..0e811be8c 100644 --- a/activemq-cpp/src/main/decaf/nio/ReadOnlyBufferException.cpp +++ b/activemq-cpp/src/main/decaf/nio/ReadOnlyBufferException.cpp @@ -17,70 +17,30 @@ #include "ReadOnlyBufferException.h" -using namespace decaf; using namespace decaf::nio; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// ReadOnlyBufferException::ReadOnlyBufferException() - : lang::exceptions::UnsupportedOperationException() + : std::logic_error("ReadOnlyBufferException") { } //////////////////////////////////////////////////////////////////////////////// -ReadOnlyBufferException::~ReadOnlyBufferException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ReadOnlyBufferException::ReadOnlyBufferException(const lang::Exception& ex) - : lang::exceptions::UnsupportedOperationException() -{ - *(lang::Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -ReadOnlyBufferException::ReadOnlyBufferException( - const ReadOnlyBufferException& ex) - : lang::exceptions::UnsupportedOperationException() +ReadOnlyBufferException::ReadOnlyBufferException(const std::string& message) + : std::logic_error(message) { - *(lang::Exception*)this = ex; } //////////////////////////////////////////////////////////////////////////////// ReadOnlyBufferException::ReadOnlyBufferException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : lang::exceptions::UnsupportedOperationException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -ReadOnlyBufferException::ReadOnlyBufferException(const std::exception* cause) - : lang::exceptions::UnsupportedOperationException(cause) + int lineNumber, + const char* message) + : std::logic_error(std::string(file) + ":" + std::to_string(lineNumber) + + ": " + message) { } //////////////////////////////////////////////////////////////////////////////// -ReadOnlyBufferException::ReadOnlyBufferException(const char* file, - const int lineNumber, - const char* msg, - ...) - : lang::exceptions::UnsupportedOperationException() +ReadOnlyBufferException::~ReadOnlyBufferException() throw() { - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); } diff --git a/activemq-cpp/src/main/decaf/nio/ReadOnlyBufferException.h b/activemq-cpp/src/main/decaf/nio/ReadOnlyBufferException.h index 92419c0b3..243bc5351 100644 --- a/activemq-cpp/src/main/decaf/nio/ReadOnlyBufferException.h +++ b/activemq-cpp/src/main/decaf/nio/ReadOnlyBufferException.h @@ -18,85 +18,32 @@ #ifndef _DECAF_NIO_READONLYBUFFEREXCEPTION_H_ #define _DECAF_NIO_READONLYBUFFEREXCEPTION_H_ -#include #include +#include +#include + namespace decaf { namespace nio { - class DECAF_API ReadOnlyBufferException - : public lang::exceptions::UnsupportedOperationException + /** + * Thrown when a buffer mutation is attempted on a read-only buffer + * (idiomatically std::logic_error). + * + * @since 1.0 + */ + class DECAF_API ReadOnlyBufferException : public std::logic_error { public: - /** - * Default Constructor - */ ReadOnlyBufferException(); - /** - * Copy Constructor - * - * @param ex the exception to copy - */ - ReadOnlyBufferException(const lang::Exception& ex); - - /** - * Copy Constructor - * - * @param ex the exception to copy, which is an instance of this type - */ - ReadOnlyBufferException(const ReadOnlyBufferException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - ReadOnlyBufferException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); + explicit ReadOnlyBufferException(const std::string& message); - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - ReadOnlyBufferException(const std::exception* cause); - - /** - * Constructor - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ ReadOnlyBufferException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - */ - virtual ReadOnlyBufferException* clone() const - { - return new ReadOnlyBufferException(*this); - } + int lineNumber, + const char* message); virtual ~ReadOnlyBufferException() throw(); }; diff --git a/activemq-cpp/src/main/decaf/nio/ShortBuffer.cpp b/activemq-cpp/src/main/decaf/nio/ShortBuffer.cpp index db894aca7..078560d88 100644 --- a/activemq-cpp/src/main/decaf/nio/ShortBuffer.cpp +++ b/activemq-cpp/src/main/decaf/nio/ShortBuffer.cpp @@ -18,15 +18,18 @@ #include "ShortBuffer.h" #include "decaf/internal/nio/BufferFactory.h" +#include #include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::internal::nio; +using activemq::exceptions::BufferUnderflowException; //////////////////////////////////////////////////////////////////////////////// ShortBuffer::ShortBuffer(int capacity) @@ -52,7 +55,7 @@ ShortBuffer* ShortBuffer::wrap(short* buffer, int size, int offset, int length) { if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ShortBuffer::wrap - Passed Buffer is Null."); @@ -60,9 +63,31 @@ ShortBuffer* ShortBuffer::wrap(short* buffer, int size, int offset, int length) return BufferFactory::createShortBuffer(buffer, size, offset, length); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -72,7 +97,7 @@ ShortBuffer* ShortBuffer::wrap(std::vector& buffer) { if (buffer.empty()) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ShortBuffer::wrap - Passed Buffer is Empty."); @@ -83,9 +108,31 @@ ShortBuffer* ShortBuffer::wrap(std::vector& buffer) 0, (int)buffer.size()); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException) - DECAF_CATCHALL_THROW(NullPointerException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (Exception& ex) + { + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -128,7 +175,7 @@ ShortBuffer& ShortBuffer::get(short* buffer, int size, int offset, int length) if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ShortBuffer::get - Passed Buffer is Null"); @@ -137,18 +184,20 @@ ShortBuffer& ShortBuffer::get(short* buffer, int size, int offset, int length) if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > remaining()) { throw BufferUnderflowException( - __FILE__, - __LINE__, - "ShortBuffer::get - Not enough data to fill length = %d", - length); + activemq::exceptions::buildSourceMessage( + __FILE__, + __LINE__, + std::string("ShortBuffer::get - Not enough data to fill " + "length = ") + + std::to_string(length))); } for (int ix = 0; ix < length; ++ix) @@ -159,8 +208,6 @@ ShortBuffer& ShortBuffer::get(short* buffer, int size, int offset, int length) return *this; } DECAF_CATCH_RETHROW(BufferUnderflowException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferUnderflowException) DECAF_CATCHALL_THROW(BufferUnderflowException) } @@ -172,9 +219,9 @@ ShortBuffer& ShortBuffer::put(ShortBuffer& src) { if (this == &src) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "ShortBuffer::put - Can't put Self"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "ShortBuffer::put - Can't put Self"); } if (this->isReadOnly()) @@ -201,8 +248,10 @@ ShortBuffer& ShortBuffer::put(ShortBuffer& src) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(IllegalArgumentException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -230,7 +279,7 @@ ShortBuffer& ShortBuffer::put(const short* buffer, if (buffer == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "ShortBuffer::put - Passed Buffer is Null."); @@ -239,9 +288,9 @@ ShortBuffer& ShortBuffer::put(const short* buffer, if (size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Arguments violate array bounds."); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Arguments violate array bounds."); } if (length > this->remaining()) @@ -261,9 +310,10 @@ ShortBuffer& ShortBuffer::put(const short* buffer, return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } @@ -281,7 +331,10 @@ ShortBuffer& ShortBuffer::put(std::vector& buffer) return *this; } DECAF_CATCH_RETHROW(BufferOverflowException) - DECAF_CATCH_RETHROW(ReadOnlyBufferException) + catch (ReadOnlyBufferException&) + { + throw; + } DECAF_CATCH_EXCEPTION_CONVERT(Exception, BufferOverflowException) DECAF_CATCHALL_THROW(BufferOverflowException) } diff --git a/activemq-cpp/src/main/decaf/nio/ShortBuffer.h b/activemq-cpp/src/main/decaf/nio/ShortBuffer.h index 5d21014d2..a9b314455 100644 --- a/activemq-cpp/src/main/decaf/nio/ShortBuffer.h +++ b/activemq-cpp/src/main/decaf/nio/ShortBuffer.h @@ -18,13 +18,12 @@ #ifndef _DECAF_NIO_SHORTBUFFER_H_ #define _DECAF_NIO_SHORTBUFFER_H_ +#include #include -#include -#include #include #include -#include #include +#include namespace decaf { @@ -87,7 +86,7 @@ namespace nio * @return the array that backs this Buffer * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual short* array() = 0; @@ -102,7 +101,7 @@ namespace nio * @return The offset into the backing array where index zero starts. * * @throws ReadOnlyBufferException if this Buffer is read only. - * @throws UnsupportedOperationException if the underlying store has no + * @throws std::logic_error if the underlying store has no * array. */ virtual int arrayOffset() = 0; @@ -182,7 +181,7 @@ namespace nio * * @return the short that is located at the given index. * - * @throws IndexOutOfBoundsException if index is not smaller than the + * @throws std::out_of_range if index is not smaller than the * buffer's limit, or the index is negative. */ virtual short get(int index) const = 0; @@ -231,8 +230,8 @@ namespace nio * * @throws BufferUnderflowException if there are fewer than length * shorts remaining in this buffer - * @throws NullPointerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the passed buffer is null. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ ShortBuffer& get(short* buffer, int size, int offset, int length); @@ -267,7 +266,7 @@ namespace nio * * @throws BufferOverflowException if there is insufficient space in * this buffer for the remaining shorts in the source buffer. - * @throws IllegalArgumentException if the source buffer is this buffer. + * @throws std::invalid_argument if the source buffer is this buffer. * @throws ReadOnlyBufferException if this buffer is read-only. */ ShortBuffer& put(ShortBuffer& src); @@ -297,8 +296,8 @@ namespace nio * @throws BufferOverflowException if there is insufficient space in * this buffer * @throws ReadOnlyBufferException if this buffer is read-only - * @throws NullPointerException if the passed buffer is null. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the passed buffer is null. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ ShortBuffer& put(const short* buffer, int size, int offset, int length); @@ -344,7 +343,7 @@ namespace nio * * @return a reference to this buffer. * - * @throws IndexOutOfBoundsException if index greater than the buffer's + * @throws std::out_of_range if index greater than the buffer's * limit minus the size of the type being written. * @throws ReadOnlyBufferException if this buffer is read-only. */ @@ -423,8 +422,8 @@ namespace nio * * @return a new ShortBuffer that is backed by buffer, caller owns. * - * @throws NullPointerException if the array pointer is NULL. - * @throws IndexOutOfBoundsException if the preconditions of size, + * @throws std::logic_error if the array pointer is NULL. + * @throws std::out_of_range if the preconditions of size, * offset, or length are not met. */ static ShortBuffer* wrap(short* array, int size, int offset, int length); diff --git a/activemq-cpp/src/main/decaf/security/MessageDigest.cpp b/activemq-cpp/src/main/decaf/security/MessageDigest.cpp index 7297eaf32..77b27e292 100644 --- a/activemq-cpp/src/main/decaf/security/MessageDigest.cpp +++ b/activemq-cpp/src/main/decaf/security/MessageDigest.cpp @@ -17,16 +17,17 @@ #include "MessageDigest.h" +#include #include #include -#include #include #include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::security; using namespace decaf::internal::security; @@ -188,7 +189,7 @@ MessageDigest* MessageDigest::clone() { if (!this->spi->isCloneable()) { - throw CloneNotSupportedException( + throw activemq::exceptions::CloneNotSupportedException( __FILE__, __LINE__, "MessageDigestSpi in use not cloneable."); diff --git a/activemq-cpp/src/main/decaf/security/MessageDigest.h b/activemq-cpp/src/main/decaf/security/MessageDigest.h index fb3851661..f16aaa3a0 100644 --- a/activemq-cpp/src/main/decaf/security/MessageDigest.h +++ b/activemq-cpp/src/main/decaf/security/MessageDigest.h @@ -50,8 +50,8 @@ namespace security * initialized state. * * Implementations are free to implement the clone method. Client - * applications can test cloneability by attempting cloning and catching the - * CloneNotSupportedException: + * applications can test cloneability by attempting cloning and catching + * std::logic_error: * * MessageDigest* md = MessageDigest::getInstance("SHA"); * @@ -61,7 +61,7 @@ namespace security * byte[] toChapter1Digest = tc1.digest(); * md.update(toChapter2); * ...etc. - * } catch (CloneNotSupportedException& ex) { + * } catch (std::logic_error& ex) { * throw DigestException("couldn't make digest of partial content"); * } * @@ -188,8 +188,7 @@ namespace security * * @return a clone of this MessageDigest if possible. * - * @throws CloneNotSupportedException if the SPI in use cannot be - * cloned. + * @throws std::logic_error if the SPI in use cannot be cloned. */ MessageDigest* clone(); diff --git a/activemq-cpp/src/main/decaf/security/MessageDigestSpi.cpp b/activemq-cpp/src/main/decaf/security/MessageDigestSpi.cpp index 727b0da63..8d9ee6113 100644 --- a/activemq-cpp/src/main/decaf/security/MessageDigestSpi.cpp +++ b/activemq-cpp/src/main/decaf/security/MessageDigestSpi.cpp @@ -17,11 +17,12 @@ #include "MessageDigestSpi.h" -#include +#include +#include +#include using namespace decaf; using namespace decaf::security; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// MessageDigestSpi::MessageDigestSpi() @@ -43,8 +44,8 @@ bool MessageDigestSpi::isCloneable() const //////////////////////////////////////////////////////////////////////////////// MessageDigestSpi* MessageDigestSpi::clone() { - throw CloneNotSupportedException( + throw activemq::exceptions::CloneNotSupportedException( __FILE__, __LINE__, - "This MessageDisgestSpi cannot be cloned."); + "This MessageDigestSpi cannot be cloned."); } diff --git a/activemq-cpp/src/main/decaf/security/MessageDigestSpi.h b/activemq-cpp/src/main/decaf/security/MessageDigestSpi.h index 5236e98cc..31b9fbf38 100644 --- a/activemq-cpp/src/main/decaf/security/MessageDigestSpi.h +++ b/activemq-cpp/src/main/decaf/security/MessageDigestSpi.h @@ -23,6 +23,7 @@ #include #include +#include #include namespace decaf @@ -44,7 +45,7 @@ namespace security * a particular message digest algorithm. * * Implementations are free to implement clone method or throw a - * CloneNotSupportedException.. + * std::logic_error. * * @since 1.0 */ @@ -68,9 +69,8 @@ namespace security * * @return a new pointer that is a copy of this object. * - * @throws CloneNotSupportedException - * if this is called on an implementation that does not support - * cloning. + * @throws std::logic_error if this is called on an implementation that + * does not support cloning. */ virtual MessageDigestSpi* clone(); @@ -103,7 +103,7 @@ namespace security * @param length * The number of bytes to use, starting at offset. * - * @throws NullPointerException if the input array pointer is NULL. + * @throws std::logic_error if the input array pointer is NULL. */ virtual void engineUpdate(const unsigned char* input, int size, @@ -168,7 +168,7 @@ namespace security * @return the length of the digest stored in the output buffer. * * @throws DigestException if an error occurs. - * @throws NullPointerException if the buffer pointer is NULL. + * @throws std::logic_error if the buffer pointer is NULL. */ virtual int engineDigest(unsigned char* buffer, int size, diff --git a/activemq-cpp/src/main/decaf/security/ProviderException.cpp b/activemq-cpp/src/main/decaf/security/ProviderException.cpp deleted file mode 100644 index 459a5b8fe..000000000 --- a/activemq-cpp/src/main/decaf/security/ProviderException.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ProviderException.h" - -using namespace decaf; -using namespace decaf::security; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -ProviderException::ProviderException() - : RuntimeException() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ProviderException::ProviderException(const Exception& ex) - : RuntimeException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -ProviderException::ProviderException(const ProviderException& ex) - : RuntimeException() -{ - *(Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -ProviderException::ProviderException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : RuntimeException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -ProviderException::ProviderException(const std::exception* cause) - : RuntimeException(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ProviderException::ProviderException(const char* file, - const int lineNumber, - const char* msg, - ...) - : RuntimeException() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -ProviderException::~ProviderException() throw() -{ -} diff --git a/activemq-cpp/src/main/decaf/security/ProviderException.h b/activemq-cpp/src/main/decaf/security/ProviderException.h deleted file mode 100644 index 789d98fbd..000000000 --- a/activemq-cpp/src/main/decaf/security/ProviderException.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DECAF_SECURITY_PROVIDEREXCEPTION_H_ -#define _DECAF_SECURITY_PROVIDEREXCEPTION_H_ - -#include - -#include - -namespace decaf -{ -namespace security -{ - - class DECAF_API ProviderException - : public decaf::lang::exceptions::RuntimeException - { - public: - /** - * Default Constructor - */ - ProviderException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * An exception that should become this type of Exception - */ - ProviderException(const Exception& ex); - - /** - * Copy Constructor - * - * @param ex - * An exception that should become this type of Exception - */ - ProviderException(const ProviderException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message. - * - * @param file - * The file name where exception occurs - * @param lineNumber - * The line number where the exception occurred. - * @param cause - * The exception that was the cause for this one to be thrown. - * @param msg - * The message to report - * @param ... - * list of primitives that are formatted into the message - */ - ProviderException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Convenience Constructor - * - * @param cause - * Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - ProviderException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file - * name where exception occurs - * @param lineNumber - * line number where the exception occurred. - * @param msg - * message to report - * @param ... - * list of primitives that are formatted into the message - */ - ProviderException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return A deep copy of this exception. - */ - virtual ProviderException* clone() const - { - return new ProviderException(*this); - } - - virtual ~ProviderException() throw(); - }; - -} // namespace security -} // namespace decaf - -#endif /* _DECAF_SECURITY_PROVIDEREXCEPTION_H_ */ diff --git a/activemq-cpp/src/main/decaf/security/SecureRandom.cpp b/activemq-cpp/src/main/decaf/security/SecureRandom.cpp index c6ae160fd..54a4ca363 100644 --- a/activemq-cpp/src/main/decaf/security/SecureRandom.cpp +++ b/activemq-cpp/src/main/decaf/security/SecureRandom.cpp @@ -17,18 +17,17 @@ #include "SecureRandom.h" -#include -#include - +#include #ifdef HAVE_PTHREAD_H #include +#include #else #include +#include +#include #endif using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::security; using namespace decaf::internal; using namespace decaf::internal::security; @@ -55,16 +54,17 @@ SecureRandom::SecureRandom(const unsigned char* seed, int size) { if (seed == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Seed buffer pointer passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Seed buffer pointer passed was NULL"); } if (size < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Passed buffer size was negative."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Passed buffer size was negative."); } if (size > 0) @@ -92,16 +92,17 @@ void SecureRandom::nextBytes(unsigned char* buf, int size) { if (buf == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer pointer passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer pointer passed was NULL"); } if (size < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Passed buffer size was negative."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Passed buffer size was negative."); } if (size > 0) @@ -144,16 +145,17 @@ void SecureRandom::setSeed(const unsigned char* seed, int size) { if (seed == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer pointer passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer pointer passed was NULL"); } if (size < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Passed buffer size was negative."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Passed buffer size was negative."); } if (size > 0) diff --git a/activemq-cpp/src/main/decaf/security/SecureRandom.h b/activemq-cpp/src/main/decaf/security/SecureRandom.h index 1594f5042..111b590e5 100644 --- a/activemq-cpp/src/main/decaf/security/SecureRandom.h +++ b/activemq-cpp/src/main/decaf/security/SecureRandom.h @@ -24,6 +24,7 @@ #include #include +#include namespace decaf { @@ -76,8 +77,8 @@ namespace security * @param size * The number of bytes in the seed buffer. * - * @throw NullPointerException if the seed buffer is NULL. - * @throw IllegalArgumentException if the size value is negative. + * @throw std::logic_error if the seed buffer is NULL. + * @throws std::invalid_argument if the size value is negative. */ SecureRandom(const unsigned char* seed, int size); @@ -109,8 +110,8 @@ namespace security * @param size * The number of bytes in the seed buffer. * - * @throw NullPointerException if the seed buffer is NULL. - * @throw IllegalArgumentException if the size value is negative. + * @throw std::logic_error if the seed buffer is NULL. + * @throws std::invalid_argument if the size value is negative. */ virtual void setSeed(const unsigned char* seed, int size); diff --git a/activemq-cpp/src/main/decaf/util/AbstractCollection.h b/activemq-cpp/src/main/decaf/util/AbstractCollection.h index 5be04d38b..04fd5ba34 100644 --- a/activemq-cpp/src/main/decaf/util/AbstractCollection.h +++ b/activemq-cpp/src/main/decaf/util/AbstractCollection.h @@ -18,16 +18,16 @@ #ifndef _DECAF_UTIL_ABSTRACTCOLLECTION_H_ #define _DECAF_UTIL_ABSTRACTCOLLECTION_H_ +#include #include -#include -#include -#include #include #include #include #include #include #include +#include +#include namespace decaf { @@ -125,11 +125,11 @@ namespace util * will probably choose to override this method for efficiency. * * Note that this implementation will throw an - * UnsupportedOperationException if the iterator returned by this + * std::logic_error if the iterator returned by this * collection's iterator method does not implement the remove method and * this collection is non-empty. * - * @throw UnsupportedOperationException + * @throws std::logic_error * if the clear operation is not supported by this collection */ virtual void clear() @@ -223,7 +223,7 @@ namespace util * * @throws UnsupportedOperationExceptio if this is an unmodifiable * collection. - * @throws IllegalStateException if the elements cannot be added at this + * @throws std::logic_error if the elements cannot be added at this * time due to insertion restrictions. */ virtual void copy(const Collection& collection) @@ -256,7 +256,7 @@ namespace util */ virtual bool add(const E& value DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "AbstractCollection add is not implemented."); @@ -320,7 +320,7 @@ namespace util * this collection with the iterator's remove method. * * Note that this implementation will throw an - * UnsupportedOperationException if the iterator returned by the + * std::logic_error if the iterator returned by the * iterator method does not implement the remove method and this * collection contains one or more elements in common with the specified * collection. @@ -350,7 +350,7 @@ namespace util * this collection with the iterator's remove method. * * Note that this implementation will throw an - * UnsupportedOperationException if the iterator returned by the + * std::logic_error if the iterator returned by the * iterator method does not implement the remove method and this * collection contains one or more elements not present in the specified * collection. diff --git a/activemq-cpp/src/main/decaf/util/AbstractList.h b/activemq-cpp/src/main/decaf/util/AbstractList.h index 1496489a4..f013a5484 100644 --- a/activemq-cpp/src/main/decaf/util/AbstractList.h +++ b/activemq-cpp/src/main/decaf/util/AbstractList.h @@ -15,20 +15,18 @@ * limitations under the License. */ +#include #ifndef _DECAF_UTIL_ABSTRACTLIST_H_ #define _DECAF_UTIL_ABSTRACTLIST_H_ #include -#include -#include -#include #include -#include #include #include #include -#include #include +#include +#include namespace decaf { @@ -97,17 +95,15 @@ namespace util { if (parent == NULL) { - throw decaf::lang::exceptions::NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "List Iterator constructed with NULL parent"); } if (start < 0 || start > parent->size()) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::IndexOutOfBoundsException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "start index passed was negative or greater than " "size()"); } @@ -130,7 +126,7 @@ namespace util { if (this->expectedModCount != this->parent->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "Concurrent Modification of Parent List detected."); @@ -145,9 +141,9 @@ namespace util return result; } - catch (decaf::lang::exceptions::IndexOutOfBoundsException& e) + catch (::activemq::exceptions::OutOfRangeException&) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "Next called without a next element to process."); @@ -158,15 +154,16 @@ namespace util { if (this->lastPosition == -1) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "Remove called before next() was called."); + "Remove called before next() was " + "called."); } if (this->expectedModCount != this->parent->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "Concurrent Modification of Parent List detected."); @@ -183,9 +180,9 @@ namespace util this->parent->removeAt(lastPosition); } - catch (decaf::lang::exceptions::IndexOutOfBoundsException& e) + catch (::activemq::exceptions::OutOfRangeException&) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "Concurrent Modification detected."); @@ -199,7 +196,7 @@ namespace util { if (this->expectedModCount != this->parent->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "Concurrent Modification of Parent List detected."); @@ -212,9 +209,9 @@ namespace util this->expectedModCount = this->parent->modCount; this->lastPosition = -1; } - catch (decaf::lang::exceptions::IndexOutOfBoundsException& e) + catch (::activemq::exceptions::OutOfRangeException&) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "Add called without a next element to process."); @@ -235,7 +232,7 @@ namespace util { if (this->expectedModCount != this->parent->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "Concurrent Modification detected."); @@ -250,9 +247,9 @@ namespace util return result; } - catch (decaf::lang::exceptions::IndexOutOfBoundsException& e) + catch (::activemq::exceptions::OutOfRangeException&) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "No previous element exists."); @@ -268,7 +265,7 @@ namespace util { if (this->expectedModCount != this->parent->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "Concurrent Modification detected."); @@ -278,9 +275,10 @@ namespace util { this->parent->set(this->lastPosition, value); } - catch (decaf::lang::exceptions::IndexOutOfBoundsException& e) + catch (::activemq::exceptions::OutOfRangeException&) { - throw decaf::lang::exceptions::IllegalStateException(); + throw activemq::exceptions::IllegalStateException( + "Set called without a valid iterator position."); } } }; @@ -307,17 +305,15 @@ namespace util { if (parent == NULL) { - throw decaf::lang::exceptions::NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "List Iterator constructed with NULL parent"); } if (start < 0 || start > parent->size()) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::IndexOutOfBoundsException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "start index passed was negative or greater than " "size()"); } @@ -340,7 +336,7 @@ namespace util { if (this->expectedModCount != this->parent->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "Concurrent Modification of Parent List detected."); @@ -355,9 +351,9 @@ namespace util return result; } - catch (decaf::lang::exceptions::IndexOutOfBoundsException& e) + catch (::activemq::exceptions::OutOfRangeException&) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "Next called without a next element to process."); @@ -366,7 +362,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "AbstractList::Iterator::remove - Const Iterator."); @@ -374,7 +370,7 @@ namespace util virtual void add(const E& value DECAF_UNUSED) { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "AbstractList::ListIterator::radd - Const Iterator."); @@ -394,7 +390,7 @@ namespace util { if (this->expectedModCount != this->parent->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "Concurrent Modification detected."); @@ -409,9 +405,9 @@ namespace util return result; } - catch (decaf::lang::exceptions::IndexOutOfBoundsException& e) + catch (::activemq::exceptions::OutOfRangeException&) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "No previous element exists."); @@ -425,7 +421,7 @@ namespace util virtual void set(const E& value DECAF_UNUSED) { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "AbstractList::ListIterator::set - Const Iterator."); @@ -485,7 +481,7 @@ namespace util virtual void add(int index DECAF_UNUSED, const E& element DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Abstract list does not implement the add method."); @@ -508,7 +504,7 @@ namespace util virtual E removeAt(int index DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Abstract list does not implement the removeAt method."); @@ -516,7 +512,7 @@ namespace util virtual E set(int index DECAF_UNUSED, const E& element DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Abstract list does not implement the set method."); diff --git a/activemq-cpp/src/main/decaf/util/AbstractMap.h b/activemq-cpp/src/main/decaf/util/AbstractMap.h index 40141afa2..500dc44c1 100644 --- a/activemq-cpp/src/main/decaf/util/AbstractMap.h +++ b/activemq-cpp/src/main/decaf/util/AbstractMap.h @@ -18,9 +18,6 @@ #ifndef _DECAF_UTIL_ABSTRACTMAP_H_ #define _DECAF_UTIL_ABSTRACTMAP_H_ -#include -#include -#include #include #include #include diff --git a/activemq-cpp/src/main/decaf/util/AbstractQueue.h b/activemq-cpp/src/main/decaf/util/AbstractQueue.h index 98c06d6f2..1c0ee3879 100644 --- a/activemq-cpp/src/main/decaf/util/AbstractQueue.h +++ b/activemq-cpp/src/main/decaf/util/AbstractQueue.h @@ -18,15 +18,14 @@ #ifndef ABSTRACTQUEUE_H_ #define ABSTRACTQUEUE_H_ +#include #include -#include -#include -#include -#include #include #include #include #include +#include +#include namespace decaf { @@ -65,7 +64,7 @@ namespace util * {@inheritDoc} * * This implementation returns true if offer succeeds, else throws an - * IllegalStateException. + * std::logic_error. */ virtual bool add(const E& value) { @@ -74,7 +73,7 @@ namespace util return true; } - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Unable to add specified element to the Queue."); @@ -84,17 +83,16 @@ namespace util * {@inheritDoc} * * This implementation checks to see if the Queue is being added to - * itself and throws an IllegalArgumentException if so, otherwise it + * itself and throws an std::invalid_argument if so, otherwise it * delegates the add to the AbstractCollection's addAll implementation. */ virtual bool addAll(const Collection& collection) { if (this == &collection) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "A Queue cannot be added to itself."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "A Queue cannot be added to itself."); } return AbstractCollection::addAll(collection); @@ -116,7 +114,7 @@ namespace util return result; } - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "Unable to remove specified element from the Queue."); @@ -126,7 +124,7 @@ namespace util * {@inheritDoc} * * This implementation returns the result of peek unless the queue is - * empty otherwise it throws a NoSuchElementException. + * empty otherwise it throws a std::runtime_error. */ virtual E element() const { @@ -136,7 +134,7 @@ namespace util return result; } - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "Unable to remove specified element from the Queue."); diff --git a/activemq-cpp/src/main/decaf/util/AbstractSequentialList.h b/activemq-cpp/src/main/decaf/util/AbstractSequentialList.h index d92327bda..40440e2a7 100644 --- a/activemq-cpp/src/main/decaf/util/AbstractSequentialList.h +++ b/activemq-cpp/src/main/decaf/util/AbstractSequentialList.h @@ -18,20 +18,22 @@ #ifndef _DECAF_UTIL_ABSTRACTSEQUENTIALLIST_H_ #define _DECAF_UTIL_ABSTRACTSEQUENTIALLIST_H_ +#include #include -#include -#include -#include #include #include #include #include +#include +#include namespace decaf { namespace util { + using namespace activemq::exceptions; + /** * This class provides a skeletal implementation of the List interface to * minimize the effort required to implement this interface backed by a @@ -93,7 +95,7 @@ namespace util virtual ListIterator* listIterator(int index DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Abstract sequential list does not implement the " @@ -102,7 +104,7 @@ namespace util virtual ListIterator* listIterator(int index DECAF_UNUSED) const { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Abstract sequential list does not implement the " @@ -124,12 +126,17 @@ namespace util this->listIterator(index)); return iter->next(); } - catch (decaf::util::NoSuchElementException& ex) + catch (NoSuchElementException&) + { + throw OutOfRangeException(std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + + "get called with invalid index."); + } + catch (ConcurrentModificationException&) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "get called with invalid index."); + throw OutOfRangeException(std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + + "get called with invalid index."); } } @@ -151,12 +158,17 @@ namespace util iter->set(element); return result; } - catch (decaf::util::NoSuchElementException& ex) + catch (NoSuchElementException&) + { + throw OutOfRangeException(std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + + "set called with invalid index."); + } + catch (ConcurrentModificationException&) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "set called with invalid index."); + throw OutOfRangeException(std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + + "set called with invalid index."); } } @@ -175,12 +187,17 @@ namespace util this->listIterator(index)); iter->add(element); } - catch (decaf::util::NoSuchElementException& ex) + catch (NoSuchElementException&) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "add called with invalid index."); + throw OutOfRangeException(std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + + "add called with invalid index."); + } + catch (ConcurrentModificationException&) + { + throw OutOfRangeException(std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + + "add called with invalid index."); } } @@ -223,12 +240,17 @@ namespace util iter->remove(); return result; } - catch (decaf::util::NoSuchElementException& ex) + catch (NoSuchElementException&) + { + throw OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "removeAt called with invalid index."); + } + catch (ConcurrentModificationException&) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "set called with invalid index."); + throw OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "removeAt called with invalid index."); } } }; diff --git a/activemq-cpp/src/main/decaf/util/AbstractSet.h b/activemq-cpp/src/main/decaf/util/AbstractSet.h index afc19344a..13e345b12 100644 --- a/activemq-cpp/src/main/decaf/util/AbstractSet.h +++ b/activemq-cpp/src/main/decaf/util/AbstractSet.h @@ -19,13 +19,11 @@ #define _DECAF_UTIL_ABSTRACTSET_H_ #include -#include -#include -#include #include #include #include #include +#include namespace decaf { @@ -74,7 +72,7 @@ namespace util * remove method. * * Note that this implementation will throw an - * UnsupportedOperationException if the iterator returned by the + * std::logic_error if the iterator returned by the * iterator method does not implement the remove method. */ virtual bool removeAll(const Collection& collection) diff --git a/activemq-cpp/src/main/decaf/util/ArrayList.h b/activemq-cpp/src/main/decaf/util/ArrayList.h index 928b18870..2e17dd226 100644 --- a/activemq-cpp/src/main/decaf/util/ArrayList.h +++ b/activemq-cpp/src/main/decaf/util/ArrayList.h @@ -18,17 +18,17 @@ #ifndef _DECAF_UTIL_ARRAYLIST_H_ #define _DECAF_UTIL_ARRAYLIST_H_ +#include #include #include -#include -#include #include #include #include #include #include -#include #include +#include +#include namespace decaf { @@ -102,10 +102,9 @@ namespace util { if (initialCapacity < 0) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Initial Capacity argument cannot be negative."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Initial Capacity argument cannot be negative."); } this->elements = new E[this->capacity]; @@ -240,10 +239,9 @@ namespace util { if (index < 0 || index >= this->curSize) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index greater than size() or negative"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index greater than size() or negative"); } E oldValue = this->elements[index]; @@ -256,10 +254,9 @@ namespace util { if (index < 0 || index >= this->curSize) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index greater than size() or negative"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index greater than size() or negative"); } return this->elements[index]; @@ -278,10 +275,9 @@ namespace util { if (index < 0 || index > this->curSize) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index was negative or greater than size()"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index was negative or greater than size()"); } if (index == 0) @@ -328,10 +324,9 @@ namespace util { if (index < 0 || index > this->curSize) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index greater than size()"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index greater than size()"); } int csize = collection.size(); @@ -381,10 +376,9 @@ namespace util { if (index < 0 || index >= this->curSize) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index greater than size() or negative"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index greater than size() or negative"); } E old = this->elements[index]; diff --git a/activemq-cpp/src/main/decaf/util/Arrays.h b/activemq-cpp/src/main/decaf/util/Arrays.h index 56e22e7b5..9c659f166 100644 --- a/activemq-cpp/src/main/decaf/util/Arrays.h +++ b/activemq-cpp/src/main/decaf/util/Arrays.h @@ -15,12 +15,12 @@ * limitations under the License. */ +#include #ifndef _DECAF_UTIL_ARRAYS_H_ #define _DECAF_UTIL_ARRAYS_H_ -#include -#include -#include +#include +#include namespace decaf { @@ -49,8 +49,9 @@ namespace util * @param value * The value to fill the array with. * - * @throws NullPointerException if array is Null. - * @throws IllegalArgumentException if the size parameter is negative, + * @throws activemq::exceptions::IllegalStateException if array + * is Null. + * @throws std::invalid_argument if the size parameter is negative, * or the start index is greater than the end index. */ template @@ -58,7 +59,7 @@ namespace util { if (array == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Array pointer given was NULL."); @@ -66,10 +67,9 @@ namespace util if (size < 0) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Array size value given was negative."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Array size value given was negative."); } for (int i = 0; i < size; ++i) @@ -92,10 +92,11 @@ namespace util * @param value * The value to fill the array with. * - * @throws NullPointerException if array is Null. - * @throws IllegalArgumentException if the size parameter is negative, + * @throws activemq::exceptions::IllegalStateException if array + * is Null. + * @throws std::invalid_argument if the size parameter is negative, * or the start index is greater than the end index. - * @throws IndexOutOfBoundsException if the start index is negative or + * @throws std::out_of_range if the start index is negative or * the end index is greater than the size parameter. */ template @@ -103,7 +104,7 @@ namespace util { if (array == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Array pointer given was NULL."); @@ -111,28 +112,25 @@ namespace util if (size < 0) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Array size value given was negative."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Array size value given was negative."); } if (start > end) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "The start index was greater than the end index."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "The start index was greater than the end index."); } if (start < 0 || end > size) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "The start index {%d} end index {%d} range is invalid.", - start, - end); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "The start index {" + std::to_string(start) + + "} end index {" + std::to_string(end) + + "} range is invalid."); } for (int i = start; i < end; ++i) diff --git a/activemq-cpp/src/main/decaf/util/BitSet.cpp b/activemq-cpp/src/main/decaf/util/BitSet.cpp index d5b80b56f..1d1105b08 100644 --- a/activemq-cpp/src/main/decaf/util/BitSet.cpp +++ b/activemq-cpp/src/main/decaf/util/BitSet.cpp @@ -17,18 +17,17 @@ #include "BitSet.h" -#include -#include -#include +#include +#include #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; //////////////////////////////////////////////////////////////////////////////// @@ -95,7 +94,10 @@ BitSet::BitSet(int bitCount) { if (bitCount < 0) { - throw NegativeArraySizeException(__FILE__, __LINE__, ""); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "BitSet size cannot be negative"); } bitsSize = (bitCount >> OFFSET) + ((bitCount & RIGHT_BITS) > 0 ? 1 : 0); @@ -103,23 +105,14 @@ BitSet::BitSet(int bitCount) { bits = new unsigned long long[bitsSize]; - if (bits == NULL) - { - throw OutOfMemoryError(__FILE__, - __LINE__, - "Failed to allocate bit array."); - } - for (int i = 0; i < bitsSize; ++i) { bits[i] = 0ULL; } } - catch (std::bad_alloc& e) + catch (std::bad_alloc&) { - throw OutOfMemoryError(__FILE__, - __LINE__, - "Failed to allocate bit array."); + throw activemq::exceptions::OutOfMemoryError(); } } @@ -164,20 +157,11 @@ BitSet::BitSet(const BitSet& set) { bits = new unsigned long long[bitsSize]; - if (bits == NULL) - { - throw OutOfMemoryError(__FILE__, - __LINE__, - "Failed to allocate bit array."); - } - System::arraycopy(set.bits, 0, bits, 0, set.bitsSize); } - catch (std::bad_alloc& e) + catch (std::bad_alloc&) { - throw OutOfMemoryError(__FILE__, - __LINE__, - "Failed to allocate bit array."); + throw activemq::exceptions::OutOfMemoryError(); } } @@ -195,20 +179,11 @@ BitSet& BitSet::operator=(const BitSet& set) { bits = new unsigned long long[bitsSize]; - if (bits == NULL) - { - throw OutOfMemoryError(__FILE__, - __LINE__, - "Failed to allocate bit array."); - } - System::arraycopy(set.bits, 0, bits, 0, set.bitsSize); } - catch (std::bad_alloc& e) + catch (std::bad_alloc&) { - throw OutOfMemoryError(__FILE__, - __LINE__, - "Failed to allocate bit array."); + throw activemq::exceptions::OutOfMemoryError(); } return *this; @@ -314,9 +289,9 @@ void BitSet::clear(int index) { if (index < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Index given was negative"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index given was negative"); } if (!needClear) @@ -339,9 +314,9 @@ void BitSet::clear(int fromIndex, int toIndex) { if (fromIndex < 0 || toIndex < 0 || toIndex < fromIndex) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Invalid from or to index given"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid from or to index given"); } if (!needClear) @@ -479,9 +454,9 @@ void BitSet::flip(int index) { if (index < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Index given was negative"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index given was negative"); } int len = (index >> OFFSET) + 1; @@ -504,9 +479,9 @@ void BitSet::flip(int fromIndex, int toIndex) { if (fromIndex < 0 || toIndex < 0 || toIndex < fromIndex) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Invalid from or to index given"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid from or to index given"); } if (fromIndex == toIndex) @@ -552,9 +527,9 @@ bool BitSet::get(int index) const { if (index < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Index given was negative"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index given was negative"); } int arrayPos = index >> OFFSET; @@ -570,9 +545,9 @@ BitSet BitSet::get(int fromIndex, int toIndex) const { if (fromIndex < 0 || toIndex < 0 || toIndex < fromIndex) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Invalid from or to index given"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid from or to index given"); } int last = actualArrayLength << OFFSET; @@ -725,9 +700,9 @@ int BitSet::nextClearBit(int index) const { if (index < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Index given was negative"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index given was negative"); } int length = actualArrayLength; @@ -777,9 +752,9 @@ int BitSet::nextSetBit(int index) const { if (index < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Index given was negative"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index given was negative"); } if (index >= actualArrayLength << OFFSET) @@ -828,9 +803,9 @@ void BitSet::set(int index) { if (index < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Index given was negative"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Index given was negative"); } int len = (index >> OFFSET) + 1; @@ -866,9 +841,9 @@ void BitSet::set(int fromIndex, int toIndex) { if (fromIndex < 0 || toIndex < 0 || toIndex < fromIndex) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "Invalid from or to index given"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Invalid from or to index given"); } if (fromIndex == toIndex) diff --git a/activemq-cpp/src/main/decaf/util/BitSet.h b/activemq-cpp/src/main/decaf/util/BitSet.h index 99078556a..034d7e32a 100644 --- a/activemq-cpp/src/main/decaf/util/BitSet.h +++ b/activemq-cpp/src/main/decaf/util/BitSet.h @@ -84,7 +84,7 @@ namespace util * @param bitCount * The number of bits this BitSet should hold. * - * @throws NegativeArraySizeException if bitCount is negative. + * @throws std::runtime_error if bitCount is negative. */ BitSet(int bitCount); @@ -172,7 +172,7 @@ namespace util * @param index * The index of the bit whose value is to be set to false * - * @throws IndexOutOfBoundsException if the index value is negative. + * @throws std::out_of_range if the index value is negative. */ void clear(int index); @@ -185,7 +185,7 @@ namespace util * @param toIndex * The index (exclusive) to stop setting bits to false. * - * @throws IndexOutOfBoundsException if fromIndex is negative, or + * @throws std::out_of_range if fromIndex is negative, or * toIndex is negative, or fromIndex is larger than toIndex. */ void clear(int fromIndex, int toIndex); @@ -211,7 +211,7 @@ namespace util * @param index * The index of the bit whose value is to be set to its compliment. * - * @throws IndexOutOfBoundsException if the index value is negative. + * @throws std::out_of_range if the index value is negative. */ void flip(int index); @@ -224,7 +224,7 @@ namespace util * @param toIndex * The index (exclusive) to stop setting bits to its compliment. * - * @throws IndexOutOfBoundsException if fromIndex is negative, or + * @throws std::out_of_range if fromIndex is negative, or * toIndex is negative, or fromIndex is larger than toIndex. */ void flip(int fromIndex, int toIndex); @@ -239,7 +239,7 @@ namespace util * * @return the value of the bit with the specified index. * - * @throws IndexOutOfBoundsException if the index value is negative. + * @throws std::out_of_range if the index value is negative. */ bool get(int index) const; @@ -254,7 +254,7 @@ namespace util * * @return a new BitSet containing the specified values. * - * @throws IndexOutOfBoundsException if fromIndex is negative, or + * @throws std::out_of_range if fromIndex is negative, or * toIndex is negative, or fromIndex is larger than toIndex. */ BitSet get(int fromIndex, int toIndex) const; @@ -296,7 +296,7 @@ namespace util * * @return the index of the next clear bit. * - * @throws IndexOutOfBoundsException if the index value is negative. + * @throws std::out_of_range if the index value is negative. */ int nextClearBit(int index) const; @@ -309,7 +309,7 @@ namespace util * * @return the index of the next set bit. * - * @throws IndexOutOfBoundsException if the index value is negative. + * @throws std::out_of_range if the index value is negative. */ int nextSetBit(int index) const; @@ -319,7 +319,7 @@ namespace util * @param index * The index to set to true. * - * @throws IndexOutOfBoundsException if the index value is negative. + * @throws std::out_of_range if the index value is negative. */ void set(int index); @@ -331,7 +331,7 @@ namespace util * @param value * The value to assign to the given bit. * - * @throws IndexOutOfBoundsException if the index value is negative. + * @throws std::out_of_range if the index value is negative. */ void set(int index, bool value); @@ -344,7 +344,7 @@ namespace util * @param toIndex * The index (exclusive) to stop at. * - * @throws IndexOutOfBoundsException if fromIndex is negative, or + * @throws std::out_of_range if fromIndex is negative, or * toIndex is negative, or fromIndex is larger than toIndex. */ void set(int fromIndex, int toIndex); @@ -360,7 +360,7 @@ namespace util * @param value * The boolean value to assign to the target bits. * - * @throws IndexOutOfBoundsException if fromIndex is negative, or + * @throws std::out_of_range if fromIndex is negative, or * toIndex is negative, or fromIndex is larger than toIndex. */ void set(int fromIndex, int toIndex, bool value); diff --git a/activemq-cpp/src/main/decaf/util/Collection.h b/activemq-cpp/src/main/decaf/util/Collection.h index 6c4abbb3f..3c11130c0 100644 --- a/activemq-cpp/src/main/decaf/util/Collection.h +++ b/activemq-cpp/src/main/decaf/util/Collection.h @@ -19,12 +19,10 @@ #define _DECAF_UTIL_COLLECTION_H_ #include -#include -#include -#include #include #include #include +#include namespace decaf { @@ -52,9 +50,9 @@ namespace util * * The "destructive" methods contained in this interface, that is, the * methods that modify the collection on which they operate, are specified - * to throw UnsupportedOperationException if this collection does not + * to throw std::logic_error if this collection does not * support the operation. If this is the case, these methods may, but are - * not required to, throw an UnsupportedOperationException if the invocation + * not required to, throw an std::logic_error if the invocation * would have no effect on the collection. For example, invoking the * addAll(Collection) method on an unmodifiable collection may, but is not * required to, throw the exception if the collection to be added is empty. @@ -84,7 +82,7 @@ namespace util * * @throws UnsupportedOperationExceptio if this is an unmodifiable * collection. - * @throws IllegalStateException if the elements cannot be added at this + * @throws std::logic_error if the elements cannot be added at this * time due to insertion restrictions. */ virtual void copy(const Collection& collection) = 0; @@ -119,11 +117,11 @@ namespace util * * @throws UnsupportedOperationExceptio if this is an unmodifiable * collection. - * @throws NullPointerException if the Collection is a container of + * @throws std::logic_error if the Collection is a container of * pointers and does not allow NULL values. - * @throws IllegalArgumentException if some property of the element + * @throws std::invalid_argument if some property of the element * prevents it from being added to this collection - * @throws IllegalStateException if the element cannot be added at this + * @throws std::logic_error if the element cannot be added at this * time due to insertion restrictions. */ virtual bool add(const E& value) = 0; @@ -143,11 +141,11 @@ namespace util * * @throws UnsupportedOperationExceptio if this is an unmodifiable * collection. - * @throws NullPointerException if the Collection is a container of + * @throws std::logic_error if the Collection is a container of * pointers and does not allow NULL values. - * @throws IllegalArgumentException if some property of an element + * @throws std::invalid_argument if some property of an element * prevents it from being added to this collection - * @throws IllegalStateException if an element cannot be added at this + * @throws std::logic_error if an element cannot be added at this * time due to insertion restrictions. */ virtual bool addAll(const Collection& collection) = 0; @@ -174,7 +172,7 @@ namespace util * @return true if there is at least one of the elements in the * collection * - * @throws NullPointerException if the Collection contains pointers and + * @throws std::logic_error if the Collection contains pointers and * the Collection does not allow for NULL elements (optional check). */ virtual bool contains(const E& value) const = 0; @@ -186,7 +184,7 @@ namespace util * @param collection * The Collection to compare to this one. * - * @throws NullPointerException if the Collection contains pointers and + * @throws std::logic_error if the Collection contains pointers and * the Collection does not allow for NULL elements (optional check). */ virtual bool containsAll(const Collection& collection) const = 0; @@ -220,7 +218,7 @@ namespace util * * @throws UnsupportedOperationExceptio if this is an unmodifiable * collection. - * @throws NullPointerException if the Collection is a container of + * @throws std::logic_error if the Collection is a container of * pointers and does not allow NULL values. */ virtual bool remove(const E& value) = 0; @@ -238,7 +236,7 @@ namespace util * * @throws UnsupportedOperationExceptio if this is an unmodifiable * collection. - * @throws NullPointerException if the Collection is a container of + * @throws std::logic_error if the Collection is a container of * pointers and does not allow NULL values. */ virtual bool removeAll(const Collection& collection) = 0; @@ -256,7 +254,7 @@ namespace util * * @throws UnsupportedOperationExceptio if this is an unmodifiable * collection. - * @throws NullPointerException if the Collection is a container of + * @throws std::logic_error if the Collection is a container of * pointers and does not allow NULL values. */ virtual bool retainAll(const Collection& collection) = 0; diff --git a/activemq-cpp/src/main/decaf/util/Collections.h b/activemq-cpp/src/main/decaf/util/Collections.h index fe4c5e5ef..7a9ddc2df 100644 --- a/activemq-cpp/src/main/decaf/util/Collections.h +++ b/activemq-cpp/src/main/decaf/util/Collections.h @@ -27,6 +27,7 @@ #include #include +#include #include namespace decaf @@ -47,7 +48,7 @@ namespace util * * @param list * The list to reverse. - * @throws UnsupportedOperationException + * @throws std::logic_error * when replacing an element in the List is not supported. */ template diff --git a/activemq-cpp/src/main/decaf/util/ConcurrentModificationException.cpp b/activemq-cpp/src/main/decaf/util/ConcurrentModificationException.cpp deleted file mode 100644 index 93383c1b1..000000000 --- a/activemq-cpp/src/main/decaf/util/ConcurrentModificationException.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ConcurrentModificationException.h" - -using namespace std; -using namespace decaf; -using namespace decaf::util; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; - -//////////////////////////////////////////////////////////////////////////////// -ConcurrentModificationException::ConcurrentModificationException() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ConcurrentModificationException::~ConcurrentModificationException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ConcurrentModificationException::ConcurrentModificationException( - const lang::Exception& ex) - : lang::exceptions::RuntimeException() -{ - *(lang::Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -ConcurrentModificationException::ConcurrentModificationException( - const ConcurrentModificationException& ex) - : lang::exceptions::RuntimeException() -{ - *(lang::Exception*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -ConcurrentModificationException::ConcurrentModificationException( - const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : lang::exceptions::RuntimeException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -ConcurrentModificationException::ConcurrentModificationException( - const std::exception* cause) - : lang::exceptions::RuntimeException(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -ConcurrentModificationException::ConcurrentModificationException( - const char* file, - const int lineNumber, - const char* msg, - ...) - : lang::exceptions::RuntimeException() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/util/ConcurrentModificationException.h b/activemq-cpp/src/main/decaf/util/ConcurrentModificationException.h deleted file mode 100755 index be99fc26b..000000000 --- a/activemq-cpp/src/main/decaf/util/ConcurrentModificationException.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DECAF_UTIL_CONCURRENTMODIFICATIONEXCEPTION_H_ -#define _DECAF_UTIL_CONCURRENTMODIFICATIONEXCEPTION_H_ - -#include -#include - -namespace decaf -{ -namespace util -{ - - class DECAF_API ConcurrentModificationException - : public lang::exceptions::RuntimeException - { - public: - /** - * Default Constructor - */ - ConcurrentModificationException(); - - /** - * Copy Constructor - * - * @param ex the exception to copy - */ - ConcurrentModificationException(const lang::Exception& ex); - - /** - * Copy Constructor - * - * @param ex the exception to copy, which is an instance of this type - */ - ConcurrentModificationException( - const ConcurrentModificationException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - ConcurrentModificationException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - ConcurrentModificationException(const std::exception* cause); - - /** - * Constructor - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - ConcurrentModificationException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - */ - virtual ConcurrentModificationException* clone() const - { - return new ConcurrentModificationException(*this); - } - - virtual ~ConcurrentModificationException() throw(); - }; - -} // namespace util -} // namespace decaf - -#endif /*_DECAF_UTIL_CONCURRENTMODIFICATIONEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/util/Date.cpp b/activemq-cpp/src/main/decaf/util/Date.cpp index f6800b7b9..ab2b15a39 100644 --- a/activemq-cpp/src/main/decaf/util/Date.cpp +++ b/activemq-cpp/src/main/decaf/util/Date.cpp @@ -16,7 +16,6 @@ */ #include -#include #include #include @@ -36,7 +35,6 @@ using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// Date::Date() diff --git a/activemq-cpp/src/main/decaf/util/Deque.h b/activemq-cpp/src/main/decaf/util/Deque.h index 4300c3161..2f7ca1529 100644 --- a/activemq-cpp/src/main/decaf/util/Deque.h +++ b/activemq-cpp/src/main/decaf/util/Deque.h @@ -18,12 +18,9 @@ #ifndef _DECAF_UTIL_DEQUE_H_ #define _DECAF_UTIL_DEQUE_H_ -#include -#include -#include #include -#include #include +#include namespace decaf { @@ -56,12 +53,12 @@ namespace util * @param element * The element to be placed at the front of the Deque. * - * @throws IllegalStateException if the element cannot be added at this + * @throws std::logic_error if the element cannot be added at this * time due to capacity restrictions - * @throws NullPointerException if the specified element is NULL and + * @throws std::logic_error if the specified element is NULL and * this deque is a Collection of pointers and does not permit null * elements. - * @throws IllegalArgumentException if some property of the specified + * @throws std::invalid_argument if some property of the specified * element prevents it from being added to this deque. */ virtual void addFirst(const E& element) = 0; @@ -74,12 +71,12 @@ namespace util * @param element * The element to be placed at the end of the Deque. * - * @throws IllegalStateException if the element cannot be added at this + * @throws std::logic_error if the element cannot be added at this * time due to capacity restrictions - * @throws NullPointerException if the specified element is NULL and + * @throws std::logic_error if the specified element is NULL and * this deque is a Collection of pointers and does not permit null * elements. - * @throws IllegalArgumentException if some property of the specified + * @throws std::invalid_argument if some property of the specified * element prevents it from being added to this deque. */ virtual void addLast(const E& element) = 0; @@ -95,10 +92,10 @@ namespace util * * @return true if the element was added, false otherwise. * - * @throws NullPointerException if the specified element is NULL and + * @throws std::logic_error if the specified element is NULL and * this deque is a Collection of pointers and does not permit null * elements. - * @throws IllegalArgumentException if some property of the specified + * @throws std::invalid_argument if some property of the specified * element prevents it from being added to this deque. */ virtual bool offerFirst(const E& element) = 0; @@ -114,10 +111,10 @@ namespace util * * @return true if the element was added, false otherwise. * - * @throws NullPointerException if the specified element is NULL and + * @throws std::logic_error if the specified element is NULL and * this deque is a Collection of pointers and does not permit null * elements. - * @throws IllegalArgumentException if some property of the specified + * @throws std::invalid_argument if some property of the specified * element prevents it from being added to this deque. */ virtual bool offerLast(const E& element) = 0; @@ -129,7 +126,7 @@ namespace util * * @return the element at the Head of the Deque. * - * @throws NoSuchElementException if the Deque is empty. + * @throws std::runtime_error if the Deque is empty. */ virtual E removeFirst() = 0; @@ -140,7 +137,7 @@ namespace util * * @return the element at the Tail of the Deque. * - * @throws NoSuchElementException if the Deque is empty. + * @throws std::runtime_error if the Deque is empty. */ virtual E removeLast() = 0; @@ -175,7 +172,7 @@ namespace util * * @return reference to the first element in the Deque. * - * @throws NoSuchElementException if the Deque is empty. + * @throws std::runtime_error if the Deque is empty. */ virtual E& getFirst() = 0; virtual const E& getFirst() const = 0; @@ -187,7 +184,7 @@ namespace util * * @return reference to the last element in the Deque. * - * @throws NoSuchElementException if the Deque is empty. + * @throws std::runtime_error if the Deque is empty. */ virtual E& getLast() = 0; virtual const E& getLast() const = 0; @@ -226,7 +223,7 @@ namespace util * * @return true if the Deque was modified as a result of this operation. * - * @throws NullPointerException if the specified element is NULL and + * @throws std::logic_error if the specified element is NULL and * this deque is a Collection of pointers and does not permit null * elements. */ @@ -241,7 +238,7 @@ namespace util * * @return true if the Deque was modified as a result of this operation. * - * @throws NullPointerException if the specified element is NULL and + * @throws std::logic_error if the specified element is NULL and * this deque is a Collection of pointers and does not permit null * elements. */ @@ -251,19 +248,19 @@ namespace util * Pushes an element onto the stack represented by this deque (in other * words, at the head of this deque) if it is possible to do so * immediately without violating capacity restrictions, otherwise it - * throwing an IllegalStateException if no space is currently available. + * throwing std::logic_error if no space is currently available. * * This method performs the same basic operation as the addFirst method. * * @param element * The element to be pushed onto the Deque. * - * @throws IllegalStateException if the element cannot be added at this + * @throws std::logic_error if the element cannot be added at this * time due to capacity restrictions - * @throws NullPointerException if the specified element is NULL and + * @throws std::logic_error if the specified element is NULL and * this deque is a Collection of pointers and does not permit null * elements. - * @throws IllegalArgumentException if some property of the specified + * @throws std::invalid_argument if some property of the specified * element prevents it from being added to this deque. */ virtual void push(const E& element) = 0; @@ -280,7 +277,7 @@ namespace util * @return the element at the front of this deque which would be the top * of a stack. * - * @throws NoSuchElementException if there is nothing on the top of the + * @throws std::runtime_error if there is nothing on the top of the * stack. */ virtual E pop() = 0; diff --git a/activemq-cpp/src/main/decaf/util/HashMap.h b/activemq-cpp/src/main/decaf/util/HashMap.h index 08de96eaa..026aee154 100644 --- a/activemq-cpp/src/main/decaf/util/HashMap.h +++ b/activemq-cpp/src/main/decaf/util/HashMap.h @@ -15,6 +15,7 @@ * limitations under the License. */ +#include #ifndef _DECAF_UTIL_HASHMAP_H_ #define _DECAF_UTIL_HASHMAP_H_ @@ -22,11 +23,13 @@ #include #include -#include #include #include -#include #include +#include + +#include +#include namespace decaf { @@ -88,18 +91,19 @@ namespace util * The iterators returned by all of this class's "collection view methods" * are fail-fast: if the map is structurally modified at any time after the * iterator is created, in any way except through the iterator's own remove - * method, the iterator will throw a ConcurrentModificationException. Thus, - * in the face of concurrent modification, the iterator fails quickly and - * cleanly, rather than risking arbitrary, non-deterministic behavior at an - * undetermined time in the future. + * method, the iterator will throw a + * activemq::exceptions::InterruptedException. Thus, in the face of + * concurrent modification, the iterator fails quickly and cleanly, rather + * than risking arbitrary, non-deterministic behavior at an undetermined + * time in the future. * * Note that the fail-fast behavior of an iterator cannot be guaranteed as * it is, generally speaking, impossible to make any hard guarantees in the * presence of unsynchronized concurrent modification. Fail-fast iterators - * throw ConcurrentModificationException on a best-effort basis. Therefore, - * it would be wrong to write a program that depended on this exception for - * its correctness: the fail-fast behavior of iterators should be used only - * to detect bugs. + * throw activemq::exceptions::InterruptedException on a best-effort + * basis. Therefore, it would be wrong to write a program that depended on + * this exception for its correctness: the fail-fast behavior of iterators + * should be used only to detect bugs. * * @since 1.0 */ @@ -192,7 +196,7 @@ namespace util { if (expectedModCount != associatedMap->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "HashMap modified outside this iterator"); @@ -205,9 +209,10 @@ namespace util if (!checkHasNext()) { - throw NoSuchElementException(__FILE__, - __LINE__, - "No next element"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "No next element"); } if (futureEntry == NULL) @@ -233,7 +238,7 @@ namespace util if (currentEntry == NULL) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Remove called before call to next()"); @@ -415,7 +420,7 @@ namespace util { if (expectedModCount != associatedMap->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "HashMap modified outside this iterator"); @@ -428,9 +433,10 @@ namespace util if (!checkHasNext()) { - throw NoSuchElementException(__FILE__, - __LINE__, - "No next element"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "No next element"); } if (futureEntry == NULL) @@ -481,7 +487,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -518,7 +524,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -555,7 +561,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -655,7 +661,7 @@ namespace util virtual void clear() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't clear a const collection"); @@ -663,7 +669,7 @@ namespace util virtual bool remove(const MapEntry& entry DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't remove from const collection"); @@ -681,7 +687,7 @@ namespace util virtual Iterator>* iterator() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't return a non-const iterator for a const collection"); @@ -783,7 +789,7 @@ namespace util virtual void clear() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't modify a const collection"); @@ -791,7 +797,7 @@ namespace util virtual bool remove(const K& key DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't modify a const collection"); @@ -799,7 +805,7 @@ namespace util virtual Iterator* iterator() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't return a non-const iterator for a const collection"); @@ -891,7 +897,7 @@ namespace util virtual void clear() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't modify a const collection"); @@ -899,7 +905,7 @@ namespace util virtual Iterator* iterator() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't return a non-const iterator for a const collection"); @@ -1016,7 +1022,7 @@ namespace util * @param capacity * The initial capacity of this hash map. * - * @throws IllegalArgumentException when the capacity is less than zero. + * @throws std::invalid_argument when the capacity is less than zero. */ HashMap(int capacity) : AbstractMap(), @@ -1043,10 +1049,9 @@ namespace util } else { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Invalid capacity configuration"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Invalid capacity configuration"); } } @@ -1058,7 +1063,7 @@ namespace util * @param loadFactor * The load factor to use for this hash map. * - * @throws IllegalArgumentException when the capacity is less than zero. + * @throws std::invalid_argument when the capacity is less than zero. */ HashMap(int capacity, float loadFactor) : AbstractMap(), @@ -1086,10 +1091,9 @@ namespace util } else { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Invalid configuration"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Invalid configuration"); } } @@ -1252,7 +1256,7 @@ namespace util return entry->getValue(); } - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "The specified key is not present in the Map"); @@ -1266,7 +1270,7 @@ namespace util return entry->getValue(); } - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "The specified key is not present in the Map"); @@ -1300,7 +1304,7 @@ namespace util return oldValue; } - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "Specified key not present in the Map."); @@ -1395,11 +1399,11 @@ namespace util } } } - catch (decaf::lang::exceptions::NullPointerException& ignored) + catch (activemq::exceptions::NullPointerException& ignored) { return false; } - catch (decaf::lang::exceptions::ClassCastException& ignored) + catch (std::bad_cast& ignored) { return false; } diff --git a/activemq-cpp/src/main/decaf/util/HashSet.h b/activemq-cpp/src/main/decaf/util/HashSet.h index b4719f9a9..09ac3849b 100644 --- a/activemq-cpp/src/main/decaf/util/HashSet.h +++ b/activemq-cpp/src/main/decaf/util/HashSet.h @@ -20,19 +20,21 @@ #include +#include #include #include -#include #include -#include #include #include +#include namespace decaf { namespace util { + using namespace activemq::exceptions; + /** * This class implements the Set interface, backed by a hash table (actually * a HashMap instance). It makes no guarantees as to the iteration order of @@ -61,7 +63,7 @@ namespace util * The iterators returned by this class's iterator method are fail-fast: if * the set is modified at any time after the iterator is created, in any way * except through the iterator's own remove method, the Iterator throws a - * ConcurrentModificationException. Thus, in the face of concurrent + * std::runtime_error. Thus, in the face of concurrent * modification, the iterator fails quickly and cleanly, rather than risking * arbitrary, non-deterministic behavior at an undetermined time in the * future. @@ -69,7 +71,7 @@ namespace util * Note that the fail-fast behavior of an iterator cannot be guaranteed as * it is, generally speaking, impossible to make any hard guarantees in the * presence of unsynchronized concurrent modification. Fail-fast iterators - * throw ConcurrentModificationException on a best-effort basis. Therefore, + * throw std::runtime_error on a best-effort basis. Therefore, * it would be wrong to write a program that depended on this exception for * its correctness: the fail-fast behavior of iterators should be used only * to detect bugs. @@ -294,7 +296,7 @@ namespace util { this->backingMap->remove(value); } - catch (decaf::util::NoSuchElementException& ex) + catch (NoSuchElementException&) { return false; } diff --git a/activemq-cpp/src/main/decaf/util/Iterator.h b/activemq-cpp/src/main/decaf/util/Iterator.h index 1270dee9a..14c07dda9 100644 --- a/activemq-cpp/src/main/decaf/util/Iterator.h +++ b/activemq-cpp/src/main/decaf/util/Iterator.h @@ -18,9 +18,7 @@ #ifndef _DECAF_UTIL_ITERATOR_H_ #define _DECAF_UTIL_ITERATOR_H_ -#include -#include -#include +#include namespace decaf { @@ -47,13 +45,13 @@ namespace util * * @return the next element in the iteration of elements. * - * @throws NoSuchElementException if the iteration has no more elements. + * @throws std::runtime_error if the iteration has no more elements. */ virtual E next() = 0; /** * Returns true if the iteration has more elements. Returns false if - * the next call to next would result in an NoSuchElementException to + * the next call to next would result in an std::runtime_error to * be thrown. * * @return true if there are more elements available for iteration. @@ -68,9 +66,9 @@ namespace util * iteration is in progress in any way other than by calling this * method. * - * @throws UnsupportedOperationException if the remove operation is + * @throws std::logic_error if the remove operation is * not supported by this Iterator. - * @throws IllegalStateException if the next method has not yet been + * @throws std::logic_error if the next method has not yet been * called, or the remove method has already been called after * the last call to the next method. */ diff --git a/activemq-cpp/src/main/decaf/util/LRUCache.h b/activemq-cpp/src/main/decaf/util/LRUCache.h index 9bdcc5e20..700b15112 100644 --- a/activemq-cpp/src/main/decaf/util/LRUCache.h +++ b/activemq-cpp/src/main/decaf/util/LRUCache.h @@ -20,8 +20,10 @@ #include -#include +#include #include +#include +#include namespace decaf { @@ -69,10 +71,9 @@ namespace util { if (maximumCacheSize <= 0) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Cache size must be greater than zero."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Cache size must be greater than zero."); } } @@ -90,7 +91,7 @@ namespace util * The ordering mode - true for access-order, false for * insertion-order. * - * @throws IllegalArgumentException if the initial capacity is negative + * @throws std::invalid_argument if the initial capacity is negative * or the load factor is non-positive. */ LRUCache(int initialCapacity, @@ -104,10 +105,9 @@ namespace util { if (maximumCacheSize <= 0) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Cache size must be greater than zero."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Cache size must be greater than zero."); } } @@ -131,17 +131,16 @@ namespace util * @param size * The new maximum cache size setting. * - * @throws IllegalArgumentException is size is less than or equal to + * @throws std::invalid_argument is size is less than or equal to * zero. */ void setMaxCacheSize(int size) { if (size <= 0) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Cache size must be greater than zero."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Cache size must be greater than zero."); } this->maxCacheSize = size; diff --git a/activemq-cpp/src/main/decaf/util/LinkedHashMap.h b/activemq-cpp/src/main/decaf/util/LinkedHashMap.h index 343f1bdcf..0363f8cc1 100644 --- a/activemq-cpp/src/main/decaf/util/LinkedHashMap.h +++ b/activemq-cpp/src/main/decaf/util/LinkedHashMap.h @@ -15,12 +15,15 @@ * limitations under the License. */ +#include #ifndef _DECAF_UTIL_LINKEDHASHMAP_H_ #define _DECAF_UTIL_LINKEDHASHMAP_H_ #include #include +#include +#include namespace decaf { @@ -110,18 +113,18 @@ namespace util * by all of this class's collection view methods are fail-fast: if the map * is structurally modified at any time after the iterator is created, in * any way except through the iterator's own remove method, the iterator - * will throw a ConcurrentModificationException. Thus, in the face of - * concurrent modification, the iterator fails quickly and cleanly, rather - * than risking arbitrary, non-deterministic behavior at an undetermined - * time in the future. + * will throw a activemq::exceptions::InterruptedException. Thus, in + * the face of concurrent modification, the iterator fails quickly and + * cleanly, rather than risking arbitrary, non-deterministic behavior at an + * undetermined time in the future. * * Note that the fail-fast behavior of an iterator cannot be guaranteed as * it is, generally speaking, impossible to make any hard guarantees in the * presence of unsynchronized concurrent modification. Fail-fast iterators - * throw ConcurrentModificationException on a best-effort basis. Therefore, - * it would be wrong to write a program that depended on this exception for - * its correctness: the fail-fast behavior of iterators should be used only - * to detect bugs. + * throw activemq::exceptions::InterruptedException on a best-effort + * basis. Therefore, it would be wrong to write a program that depended on + * this exception for its correctness: the fail-fast behavior of iterators + * should be used only to detect bugs. * * @since 1.0 */ @@ -190,7 +193,7 @@ namespace util { if (expectedModCount != associatedMap->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "LinkedHashMap modified outside this iterator"); @@ -207,7 +210,7 @@ namespace util checkConcurrentMod(); if (!checkHasNext()) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "No next element"); @@ -221,10 +224,11 @@ namespace util checkConcurrentMod(); if (currentEntry == NULL) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "Remove called before call to next()"); + "Remove called before call to " + "next()"); } LinkedHashMapEntry* entry = currentEntry; @@ -399,7 +403,7 @@ namespace util { if (expectedModCount != associatedMap->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "LinkedHashMap modified outside this iterator"); @@ -411,7 +415,7 @@ namespace util checkConcurrentMod(); if (!checkHasNext()) { - throw decaf::util::NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "No next element"); @@ -451,7 +455,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -488,7 +492,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -525,7 +529,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -591,7 +595,7 @@ namespace util virtual Iterator>* iterator() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't return a non-const iterator for a const collection"); @@ -749,7 +753,7 @@ namespace util * @param capacity * The initial capacity of this map. * - * @throws IllegalArgumentException if the capacity is less than zero. + * @throws std::invalid_argument if the capacity is less than zero. */ LinkedHashMap(int capacity) : HashMap(capacity), @@ -768,7 +772,7 @@ namespace util * @param load * The initial load factor for this map. * - * @throws IllegalArgumentException + * @throws std::invalid_argument * If the capacity is less than zero or the load factor is less or * equal to zero. */ @@ -794,7 +798,7 @@ namespace util * if the ordering should be the order in which the entries were * inserted. * - * @throws IllegalArgumentException + * @throws std::invalid_argument * If the capacity is less than zero or the load factor is less or * equal to zero. */ @@ -934,7 +938,7 @@ namespace util return oldValue; } - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "Specified key not present in the Map."); diff --git a/activemq-cpp/src/main/decaf/util/LinkedHashSet.h b/activemq-cpp/src/main/decaf/util/LinkedHashSet.h index b98481a14..536350bf0 100644 --- a/activemq-cpp/src/main/decaf/util/LinkedHashSet.h +++ b/activemq-cpp/src/main/decaf/util/LinkedHashSet.h @@ -20,10 +20,9 @@ #include -#include -#include #include #include +#include namespace decaf { @@ -86,7 +85,7 @@ namespace util * The iterators returned by this class's iterator method are fail-fast: if * the set is modified at any time after the iterator is created, in any way * except through the iterator's own remove method, the iterator will throw - * a ConcurrentModificationException. Thus, in the face of concurrent + * a std::runtime_error. Thus, in the face of concurrent * modification, the iterator fails quickly and cleanly, rather than risking * arbitrary, non-deterministic behavior at an undetermined time in the * future. @@ -94,7 +93,7 @@ namespace util * Note that the fail-fast behavior of an iterator cannot be guaranteed as * it is, generally speaking, impossible to make any hard guarantees in the * presence of unsynchronized concurrent modification. Fail-fast iterators - * throw ConcurrentModificationException on a best-effort basis. Therefore, + * throw std::runtime_error on a best-effort basis. Therefore, * it would be wrong to write a program that depended on this exception for * its correctness: the fail-fast behavior of iterators should be used only * to detect bugs. diff --git a/activemq-cpp/src/main/decaf/util/LinkedList.h b/activemq-cpp/src/main/decaf/util/LinkedList.h index c13d93f79..3d08b5937 100644 --- a/activemq-cpp/src/main/decaf/util/LinkedList.h +++ b/activemq-cpp/src/main/decaf/util/LinkedList.h @@ -15,22 +15,22 @@ * limitations under the License. */ +#include #ifndef _DECAF_UTIL_LINKEDLIST_H_ #define _DECAF_UTIL_LINKEDLIST_H_ #include #include -#include -#include #include #include #include #include #include #include -#include #include #include +#include +#include namespace decaf { @@ -176,11 +176,10 @@ namespace util { if (index < 0 || index >= this->listSize) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index given is outside bounds of this list {%d}", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index given is outside bounds of this list {" + + std::to_string(index) + "}"); } const ListNode* location = NULL; @@ -209,11 +208,10 @@ namespace util { if (index < 0 || index >= this->listSize) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index given is outside bounds of this list {%d}", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index given is outside bounds of this list {" + + std::to_string(index) + "}"); } ListNode* location = NULL; @@ -251,11 +249,10 @@ namespace util { if (index < 0 || index > this->listSize) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index given is outside bounds of this list {%d}", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index given is outside bounds of this list {" + + std::to_string(index) + "}"); } this->addAtLocation(index, value); @@ -403,9 +400,10 @@ namespace util { if (this->listSize == 0) { - throw decaf::util::NoSuchElementException(__FILE__, - __LINE__, - "The list is Empty"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "The list is Empty"); } return this->head.next->value; @@ -425,9 +423,10 @@ namespace util { if (this->listSize == 0) { - throw decaf::util::NoSuchElementException(__FILE__, - __LINE__, - "The list is Empty"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "The list is Empty"); } return this->head.next->value; @@ -437,9 +436,10 @@ namespace util { if (this->listSize == 0) { - throw decaf::util::NoSuchElementException(__FILE__, - __LINE__, - "The list is Empty"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "The list is Empty"); } return this->head.next->value; @@ -449,9 +449,10 @@ namespace util { if (this->listSize == 0) { - throw decaf::util::NoSuchElementException(__FILE__, - __LINE__, - "The list is Empty"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "The list is Empty"); } return this->tail.prev->value; @@ -461,9 +462,10 @@ namespace util { if (this->listSize == 0) { - throw decaf::util::NoSuchElementException(__FILE__, - __LINE__, - "The list is Empty"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "The list is Empty"); } return this->tail.prev->value; @@ -602,19 +604,16 @@ namespace util { if (list == NULL) { - throw decaf::lang::exceptions::NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Parent LinkedList pointer was Null."); } if (index < 0 || index > list->listSize) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Given index {%d} is out of range.", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Given index {" + std::to_string(index) + + "} is out of range."); } this->expectedModCount = list->modCount; @@ -653,7 +652,7 @@ namespace util { if (this->expectedModCount != this->list->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "List modified outside of this Iterator."); @@ -661,7 +660,7 @@ namespace util if (this->current->next == &(this->list->tail)) { - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "No more elements to return from next()"); @@ -683,7 +682,7 @@ namespace util { if (this->expectedModCount != this->list->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "List modified outside of this Iterator."); @@ -691,10 +690,11 @@ namespace util if (this->current == &(this->list->head)) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "No previous element, must call next() before calling " + "No previous element, must call " + "next() before calling " "previous()."); } @@ -714,7 +714,7 @@ namespace util { if (this->expectedModCount != this->list->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "List modified outside of this Iterator."); @@ -722,10 +722,11 @@ namespace util if (this->lastReturned == NULL) { - throw lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "Invalid State to call remove, must call next() before " + "Invalid State to call remove, must " + "call next() before " "remove()"); } @@ -755,7 +756,7 @@ namespace util { if (this->expectedModCount != this->list->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "List modified outside of this Iterator."); @@ -780,7 +781,7 @@ namespace util { if (this->expectedModCount != this->list->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "List modified outside of this Iterator."); @@ -792,10 +793,9 @@ namespace util } else { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, - "Iterator next has not been called."); + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Iterator next has not been called."); } } @@ -832,19 +832,16 @@ namespace util { if (list == NULL) { - throw decaf::lang::exceptions::NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Parent LinkedList pointer was Null."); } if (index < 0 || index > list->listSize) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Given index {%d} is out of range.", - index); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Given index {" + std::to_string(index) + + "} is out of range."); } // index starts at -1 to indicate that we are before begin or @@ -881,7 +878,7 @@ namespace util { if (this->current->next == &(this->list->tail)) { - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "No more elements to return from this ListIterator"); @@ -903,10 +900,11 @@ namespace util { if (this->current == &(this->list->head)) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "No previous element, must call next() before calling " + "No previous element, must call " + "next() before calling " "previous()."); } @@ -924,7 +922,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const ListIterator."); @@ -932,7 +930,7 @@ namespace util virtual void add(const E& e DECAF_UNUSED) { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const ListIterator."); @@ -940,7 +938,7 @@ namespace util virtual void set(const E& e DECAF_UNUSED) { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const ListIterator."); @@ -979,9 +977,7 @@ namespace util { if (list == NULL) { - throw decaf::lang::exceptions::NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Parent LinkedList pointer was Null."); } @@ -1002,7 +998,7 @@ namespace util { if (this->expectedModCount != this->list->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "List modified outside of this Iterator."); @@ -1010,7 +1006,7 @@ namespace util if (this->current->prev == &(this->list->head)) { - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "No more elements to return from next()"); @@ -1026,7 +1022,7 @@ namespace util { if (this->expectedModCount != this->list->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "List modified outside of this Iterator."); @@ -1034,10 +1030,11 @@ namespace util if (!this->canRemove) { - throw lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "Invalid State to call remove, must call next() before " + "Invalid State to call remove, must " + "call next() before " "remove()"); } @@ -1076,9 +1073,7 @@ namespace util { if (list == NULL) { - throw decaf::lang::exceptions::NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Parent LinkedList pointer was Null."); } @@ -1098,7 +1093,7 @@ namespace util { if (this->current->prev == &(this->list->head)) { - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "No more elements to return from next()"); @@ -1111,7 +1106,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -1146,9 +1141,10 @@ namespace util { if (this->head.next == &this->tail) { - throw NoSuchElementException(__FILE__, - __LINE__, - "The Collection is empty."); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "The Collection is empty."); } ListNode* oldNode = this->head.next; @@ -1169,9 +1165,10 @@ namespace util { if (this->head.next == &this->tail) { - throw NoSuchElementException(__FILE__, - __LINE__, - "The Collection is empty."); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "The Collection is empty."); } ListNode* oldNode = this->tail.prev; @@ -1247,9 +1244,9 @@ namespace util { if (index < 0 || index > this->listSize) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index for add is outside bounds of this LinkedList."); } diff --git a/activemq-cpp/src/main/decaf/util/List.h b/activemq-cpp/src/main/decaf/util/List.h index 52d380e18..64972865b 100644 --- a/activemq-cpp/src/main/decaf/util/List.h +++ b/activemq-cpp/src/main/decaf/util/List.h @@ -18,14 +18,13 @@ #ifndef _DECAF_UTIL_LIST_H_ #define _DECAF_UTIL_LIST_H_ -#include #include #include #include #include #include -#include #include +#include namespace decaf { @@ -82,7 +81,7 @@ namespace util * an initial call to next. An initial call to previous would return the * element with the specified index minus one. * - * @throws IndexOutOfBoundsException if the index is out of range + * @throws std::out_of_range if the index is out of range * (index < 0 || index > size()) */ virtual ListIterator* listIterator(int index) = 0; @@ -100,7 +99,7 @@ namespace util * @return the index of the first occurrence of the specified element in * this list, * - * @throws NullPointerException if the Collection is a container of + * @throws std::logic_error if the Collection is a container of * pointers and does not allow NULL values. */ virtual int indexOf(const E& value) const = 0; @@ -117,7 +116,7 @@ namespace util * @return the index of the last occurrence of the specified element in * this list. * - * @throws NullPointerException if the Collection is a container of + * @throws std::logic_error if the Collection is a container of * pointers and does not allow NULL values. */ virtual int lastIndexOf(const E& value) const = 0; @@ -130,7 +129,7 @@ namespace util * * @return value at index specified. * - * @throws IndexOutOfBoundsException if the index given is less than + * @throws std::out_of_range if the index given is less than * zero or greater than the List size. */ virtual E get(int index) const = 0; @@ -146,15 +145,15 @@ namespace util * * @return the element previously at the specified position. * - * @throws IndexOutOfBoundsException if the index given is less than + * @throws std::out_of_range if the index given is less than * zero or greater than the List size. * @throws UnsupportedOperationExceptio if this is an unmodifiable * collection. - * @throws NullPointerException if the Collection is a container of + * @throws std::logic_error if the Collection is a container of * pointers and does not allow NULL values. - * @throws IllegalArgumentException if some property of the element + * @throws std::invalid_argument if some property of the element * prevents it from being added to this collection - * @throws IllegalStateException if the element cannot be added at this + * @throws std::logic_error if the element cannot be added at this * time due to insertion restrictions. */ virtual E set(int index, const E& element) = 0; @@ -169,15 +168,15 @@ namespace util * @param element * The element to be inserted in this List. * - * @throws IndexOutOfBoundsException if the index is greater than size + * @throws std::out_of_range if the index is greater than size * of the List. * @throws UnsupportedOperationExceptio if this is an unmodifiable * collection. - * @throws NullPointerException if the Collection is a container of + * @throws std::logic_error if the Collection is a container of * pointers and does not allow NULL values. - * @throws IllegalArgumentException if some property of the element + * @throws std::invalid_argument if some property of the element * prevents it from being added to this collection - * @throws IllegalStateException if the element cannot be added at this + * @throws std::logic_error if the element cannot be added at this * time due to insertion restrictions. */ virtual void add(int index, const E& element) = 0; @@ -201,15 +200,15 @@ namespace util * * @return true if this list changed as a result of the call * - * @throws IndexOutOfBoundsException if the index given is less than + * @throws std::out_of_range if the index given is less than * zero or greater than the List size. * @throws UnsupportedOperationExceptio if this is an unmodifiable * collection. - * @throws NullPointerException if the Collection is a container of + * @throws std::logic_error if the Collection is a container of * pointers and does not allow NULL values. - * @throws IllegalArgumentException if some property of the element + * @throws std::invalid_argument if some property of the element * prevents it from being added to this collection - * @throws IllegalStateException if the element cannot be added at this + * @throws std::logic_error if the element cannot be added at this * time due to insertion restrictions. */ virtual bool addAll(int index, const Collection& source) = 0; @@ -223,7 +222,7 @@ namespace util * * @return the element previously at the specified position. * - * @throws IndexOutOfBoundsException if the index given is less than + * @throws std::out_of_range if the index given is less than * zero or greater than the List size. * @throws UnsupportedOperationExceptio if this is an unmodifiable * collection. diff --git a/activemq-cpp/src/main/decaf/util/ListIterator.h b/activemq-cpp/src/main/decaf/util/ListIterator.h index cdc6ead58..89d347655 100644 --- a/activemq-cpp/src/main/decaf/util/ListIterator.h +++ b/activemq-cpp/src/main/decaf/util/ListIterator.h @@ -18,9 +18,9 @@ #ifndef _DECAF_UTIL_LISTITERATOR_H_ #define _DECAF_UTIL_LISTITERATOR_H_ -#include #include #include +#include namespace decaf { @@ -58,9 +58,9 @@ namespace util * @param e * The element to insert into the List. * - * @throw UnsupportedOperationException if the add method is not + * @throws std::logic_error if the add method is not * supported by this list iterator. - * @throw IllegalArgumentException if some aspect of this element + * @throws std::invalid_argument if some aspect of this element * prevents it from being added to this list. */ virtual void add(const E& e) = 0; @@ -75,11 +75,11 @@ namespace util * The element with which to replace the last element returned * by next or previous. * - * @throw UnsupportedOperationException if the add method is not + * @throws std::logic_error if the add method is not * supported by this list iterator. - * @throw IllegalArgumentException if some aspect of this element + * @throws std::invalid_argument if some aspect of this element * prevents it from being added to this list. - * @throw IllegalStateException if neither next nor previous have been + * @throw std::logic_error if neither next nor previous have been * called, or remove or add have been called after the last call * to next or previous. */ @@ -103,7 +103,7 @@ namespace util * * @return the previous element in the list. * - * @throw NoSuchElementException if the iteration has no previous + * @throw std::runtime_error if the iteration has no previous * element. */ virtual E previous() = 0; diff --git a/activemq-cpp/src/main/decaf/util/Map.h b/activemq-cpp/src/main/decaf/util/Map.h index 5d9bb99d1..dd0cc8593 100644 --- a/activemq-cpp/src/main/decaf/util/Map.h +++ b/activemq-cpp/src/main/decaf/util/Map.h @@ -18,13 +18,12 @@ #ifndef _DECAF_UTIL_MAP_H_ #define _DECAF_UTIL_MAP_H_ -#include #include #include -#include #include #include #include +#include #include namespace decaf @@ -60,9 +59,9 @@ namespace util * * The "destructive" methods contained in this interface, that is, the * methods that modify the map on which they operate, are specified to throw - * UnsupportedOperationException if this map does not support the operation. + * std::logic_error if this map does not support the operation. * If this is the case, these methods may, but are not required to, throw an - * UnsupportedOperationException if the invocation would have no effect on + * std::logic_error if the invocation would have no effect on * the map. For example, invoking the putAll(Map) method on an unmodifiable * map may, but is not required to, throw the exception if the map whose * mappings are to be "superimposed" is empty. @@ -71,7 +70,7 @@ namespace util * may contain. For example, some implementations prohibit NULL keys and * values, and some have restrictions on the types of their keys. Attempting * to insert an ineligible key or value throws an exception, typically - * NullPointerException or ClassCastException. Attempting to query the + * std::logic_error or std::bad_cast. Attempting to query the * presence of an ineligible key or value may throw an exception, or it may * simply return false; some implementations will exhibit the former * behavior and some will exhibit the latter. More generally, attempting an @@ -144,7 +143,7 @@ namespace util * Removes all of the mappings from this map (optional operation). The * map will be empty after this call returns. * - * @throw UnsupportedOperationException if the clear operation is not + * @throws std::logic_error if the clear operation is not * supported by this map. */ virtual void clear() = 0; @@ -190,7 +189,7 @@ namespace util /** * Gets the value mapped to the specified key in the Map. If there is * no element in the map whose key is equivalent to the key provided - * then a NoSuchElementException is thrown. + * then a std::runtime_error is thrown. * * @param key * The search key whose value should be returned if present. @@ -198,7 +197,7 @@ namespace util * @return A reference to the value for the given key if present in the * Map. * - * @throws NoSuchElementException if the key requests doesn't exist in + * @throws std::runtime_error if the key requests doesn't exist in * the Map. */ virtual V& get(const K& key) = 0; @@ -206,7 +205,7 @@ namespace util /** * Gets the value mapped to the specified key in the Map. If there is * no element in the map whose key is equivalent to the key provided - * then a NoSuchElementException is thrown. + * then a std::runtime_error is thrown. * * @param key * The search key whose value should be returned if present. @@ -214,7 +213,7 @@ namespace util * @return A const reference to the value for the given key if present * in the Map. * - * @throws NoSuchElementException if the key requests doesn't exist in + * @throws std::runtime_error if the key requests doesn't exist in * the Map. */ virtual const V& get(const K& key) const = 0; @@ -235,8 +234,8 @@ namespace util * associated with an existing mapping to the given key or false * otherwise. * - * @throws UnsupportedOperationException if this map is unmodifiable. - * @throws IllegalArgumentException if some property of the specified + * @throws std::logic_error if this map is unmodifiable. + * @throws std::invalid_argument if some property of the specified * key or value prevents it from being stored in this map */ virtual bool put(const K& key, const V& value) = 0; @@ -264,8 +263,8 @@ namespace util * associated with an existing mapping to the given key or false * otherwise. * - * @throws UnsupportedOperationException if this map is unmodifiable. - * @throws IllegalArgumentException if some property of the specified + * @throws std::logic_error if this map is unmodifiable. + * @throws std::invalid_argument if some property of the specified * key or value prevents it from being stored in this map */ virtual bool put(const K& key, const V& value, V& oldValue) = 0; @@ -282,7 +281,7 @@ namespace util * A Map instance whose elements are to all be inserted in this * Map. * - * @throws UnsupportedOperationException + * @throws std::logic_error * If the implementing class does not support the putAll operation. */ virtual void putAll(const Map& other) = 0; @@ -299,8 +298,8 @@ namespace util * @return a copy of the element that was previously mapped to the given * key. * - * @throw NoSuchElementException if this key is not in the Map. - * @throw UnsupportedOperationException if this map is unmodifiable. + * @throw std::runtime_error if this key is not in the Map. + * @throws std::logic_error if this map is unmodifiable. */ virtual V remove(const K& key) = 0; diff --git a/activemq-cpp/src/main/decaf/util/NoSuchElementException.cpp b/activemq-cpp/src/main/decaf/util/NoSuchElementException.cpp deleted file mode 100644 index 30a908e9f..000000000 --- a/activemq-cpp/src/main/decaf/util/NoSuchElementException.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "NoSuchElementException.h" - -using namespace decaf; -using namespace decaf::util; - -//////////////////////////////////////////////////////////////////////////////// -NoSuchElementException::NoSuchElementException() - : decaf::lang::exceptions::RuntimeException() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NoSuchElementException::~NoSuchElementException() throw() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NoSuchElementException::NoSuchElementException( - const decaf::lang::exceptions::RuntimeException& ex) - : decaf::lang::exceptions::RuntimeException() -{ - *(decaf::lang::exceptions::RuntimeException*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -NoSuchElementException::NoSuchElementException(const NoSuchElementException& ex) - : decaf::lang::exceptions::RuntimeException() -{ - *(decaf::lang::exceptions::RuntimeException*)this = ex; -} - -//////////////////////////////////////////////////////////////////////////////// -NoSuchElementException::NoSuchElementException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...) - : decaf::lang::exceptions::RuntimeException(cause) -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} - -//////////////////////////////////////////////////////////////////////////////// -NoSuchElementException::NoSuchElementException(const std::exception* cause) - : decaf::lang::exceptions::RuntimeException(cause) -{ -} - -//////////////////////////////////////////////////////////////////////////////// -NoSuchElementException::NoSuchElementException(const char* file, - const int lineNumber, - const char* msg, - ...) - : decaf::lang::exceptions::RuntimeException() -{ - va_list vargs; - va_start(vargs, msg); - buildMessage(msg, vargs); - - // Set the first mark for this exception. - setMark(file, lineNumber); -} diff --git a/activemq-cpp/src/main/decaf/util/NoSuchElementException.h b/activemq-cpp/src/main/decaf/util/NoSuchElementException.h deleted file mode 100644 index 52aed2db9..000000000 --- a/activemq-cpp/src/main/decaf/util/NoSuchElementException.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _DECAF_UTIL_NOSUCHELEMENTEXCEPTION_H_ -#define _DECAF_UTIL_NOSUCHELEMENTEXCEPTION_H_ - -#include - -namespace decaf -{ -namespace util -{ - - /* - * Thrown from an operation that attempts to access some element that does - * not exist. - * - * @since 1.0 - */ - class DECAF_API NoSuchElementException - : public decaf::lang::exceptions::RuntimeException - { - public: - /** - * Default Constructor - */ - NoSuchElementException(); - - /** - * Conversion Constructor from some other Exception - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - NoSuchElementException( - const decaf::lang::exceptions::RuntimeException& ex); - - /** - * Copy Constructor - * - * @param ex - * The Exception whose data is to be copied into this one. - */ - NoSuchElementException(const NoSuchElementException& ex); - - /** - * Constructor - Initializes the file name and line number where - * this message occurred. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param cause The exception that was the cause for this one to be - * thrown. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - NoSuchElementException(const char* file, - const int lineNumber, - const std::exception* cause, - const char* msg, - ...); - - /** - * Constructor - * - * @param cause Pointer to the exception that caused this one to - * be thrown, the object is cloned caller retains ownership. - */ - NoSuchElementException(const std::exception* cause); - - /** - * Constructor - Initializes the file name and line number where - * this message occured. Sets the message to report, using an - * optional list of arguments to parse into the message - * - * @param file The file name where exception occurs - * @param lineNumber The line number where the exception occurred. - * @param msg The message to report - * @param ... list of primitives that are formatted into the message - */ - NoSuchElementException(const char* file, - const int lineNumber, - const char* msg, - ...); - - /** - * Clones this exception. This is useful for cases where you need - * to preserve the type of the original exception as well as the - * message. All subclasses should override. - * - * @return an new Exception instance that is a copy of this one. - */ - virtual NoSuchElementException* clone() const - { - return new NoSuchElementException(*this); - } - - virtual ~NoSuchElementException() throw(); - }; - -} // namespace util -} // namespace decaf - -#endif /*_DECAF_UTIL_NOSUCHELEMENTEXCEPTION_H_*/ diff --git a/activemq-cpp/src/main/decaf/util/PriorityQueue.h b/activemq-cpp/src/main/decaf/util/PriorityQueue.h index d2ebe1a03..64f8f8b9f 100644 --- a/activemq-cpp/src/main/decaf/util/PriorityQueue.h +++ b/activemq-cpp/src/main/decaf/util/PriorityQueue.h @@ -15,6 +15,7 @@ * limitations under the License. */ +#include #ifndef _DECAF_UTIL_PRIORITYQUEUE_H_ #define _DECAF_UTIL_PRIORITYQUEUE_H_ @@ -27,10 +28,10 @@ #include #include -#include -#include #include +#include +#include namespace decaf { @@ -119,7 +120,7 @@ namespace util { if (!hasNext()) { - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "No more elements to Iterate over."); @@ -138,10 +139,11 @@ namespace util { if (!allowRemove) { - throw lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "No more elements to Iterate over."); + "Iterator remove called without a " + "prior next()."); } allowRemove = false; @@ -164,9 +166,9 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( - __FILE__, - __LINE__, + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "PriorityQueue::Iterator::remove - Not Valid on a Const " "Iterator"); } @@ -215,7 +217,8 @@ namespace util * The Comparator instance to use in sorting the elements in the * Queue. * - * @throws NullPointerException if the passed Comparator is NULL. + * @throws activemq::exceptions::IllegalStateException if the + * passed Comparator is NULL. */ PriorityQueue(int initialCapacity, Comparator* comparator) : AbstractQueue(), @@ -226,7 +229,7 @@ namespace util { if (comparator == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Passed Comparator Cannot be NULL."); @@ -374,9 +377,7 @@ namespace util return result; } - throw decaf::util::NoSuchElementException( - __FILE__, - __LINE__, + throw activemq::exceptions::InterruptedException( "Unable to remove specified element from the Queue."); } @@ -406,14 +407,32 @@ namespace util { return offer(value); } - DECAF_CATCH_RETHROW(lang::exceptions::UnsupportedOperationException) - DECAF_CATCH_RETHROW(lang::exceptions::IllegalArgumentException) - DECAF_CATCH_RETHROW(lang::exceptions::IllegalStateException) - DECAF_CATCH_EXCEPTION_CONVERT( - lang::exceptions::NullPointerException, - lang::exceptions::UnsupportedOperationException) - DECAF_CATCHALL_THROW( - lang::exceptions::UnsupportedOperationException) + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::UnsupportedOperationException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (activemq::exceptions::NullPointerException& ex) + { + throw activemq::exceptions::UnsupportedOperationException( + __FILE__, + __LINE__, + ex.what()); + } + catch (...) + { + throw activemq::exceptions::UnsupportedOperationException( + __FILE__, + __LINE__, + "caught unknown exception"); + } } /** diff --git a/activemq-cpp/src/main/decaf/util/Properties.cpp b/activemq-cpp/src/main/decaf/util/Properties.cpp index 03a7c2a4d..d292e577c 100644 --- a/activemq-cpp/src/main/decaf/util/Properties.cpp +++ b/activemq-cpp/src/main/decaf/util/Properties.cpp @@ -17,20 +17,21 @@ #include "Properties.h" +#include #include #include #include -#include #include #include #include #include #include +#include +#include using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; //////////////////////////////////////////////////////////////////////////////// @@ -397,9 +398,10 @@ void Properties::load(decaf::io::InputStream* stream) { if (stream == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The Stream instance passed was Null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The Stream instance passed was Null"); } int mode = PARSE_MODE_NONE; @@ -573,8 +575,6 @@ void Properties::load(decaf::io::InputStream* stream) } } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IllegalArgumentException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } @@ -586,18 +586,18 @@ void Properties::load(decaf::io::Reader* reader) { if (reader == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The Reader instance passed was Null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The Reader instance passed was Null"); } - throw UnsupportedOperationException(__FILE__, - __LINE__, - "Not yet Implemented."); + throw activemq::exceptions::UnsupportedOperationException( + __FILE__, + __LINE__, + "Not yet Implemented."); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IllegalArgumentException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } @@ -610,7 +610,7 @@ void Properties::store(decaf::io::OutputStream* out, { if (out == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The OutputStream instance passed was Null"); @@ -654,7 +654,6 @@ void Properties::store(decaf::io::OutputStream* out, out->flush(); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } @@ -667,17 +666,18 @@ void Properties::store(decaf::io::Writer* writer, { if (writer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The Writer instance passed was Null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The Writer instance passed was Null"); } - throw UnsupportedOperationException(__FILE__, - __LINE__, - "Not yet Implemented."); + throw activemq::exceptions::UnsupportedOperationException( + __FILE__, + __LINE__, + "Not yet Implemented."); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/util/Properties.h b/activemq-cpp/src/main/decaf/util/Properties.h index 31287d039..c5f11c833 100644 --- a/activemq-cpp/src/main/decaf/util/Properties.h +++ b/activemq-cpp/src/main/decaf/util/Properties.h @@ -22,10 +22,9 @@ #include #include #include -#include -#include #include #include +#include #include #include @@ -230,10 +229,6 @@ namespace util * @param stream * The stream to read the properties data from. * - * @throw IOException if there is an error while reading from the - * stream. - * @throw IllegalArgumentException if malformed data is found while - * reading the properties. * @throw NullPointerException if the passed stream is Null. */ void load(decaf::io::InputStream* stream); @@ -336,10 +331,6 @@ namespace util * @param reader * The Reader that provides an character stream as input. * - * @throw IOException if there is an error while reading from the - * stream. - * @throw IllegalArgumentException if malformed data is found while - * reading the properties. * @throw NullPointerException if the passed stream is Null. */ void load(decaf::io::Reader* reader); @@ -371,8 +362,6 @@ namespace util * A description of these properties that is written to the output * stream. * - * @throw IOException if there is an error while writing from the - * stream. * @throw NullPointerException if the passed stream is Null. */ void store(decaf::io::OutputStream* out, const std::string& comment); @@ -411,8 +400,6 @@ namespace util * A description of these properties that is written before writing * the properties. * - * @throw IOException if there is an error while writing from the - * stream. * @throw NullPointerException if the passed stream is Null. */ void store(decaf::io::Writer* writer, const std::string& comments); diff --git a/activemq-cpp/src/main/decaf/util/Queue.h b/activemq-cpp/src/main/decaf/util/Queue.h index 8edd43184..fed5edf36 100644 --- a/activemq-cpp/src/main/decaf/util/Queue.h +++ b/activemq-cpp/src/main/decaf/util/Queue.h @@ -18,11 +18,10 @@ #define _DECAF_UTIL_QUEUE_H_ #include -#include #include #include #include -#include +#include namespace decaf { @@ -73,9 +72,9 @@ namespace util * * @return true if the operation succeeds and false if it fails. * - * @throws NullPointerException if the Queue implementation does not + * @throws std::logic_error if the Queue implementation does not * allow Null values to be inserted into the Queue. - * @throws IllegalArgumentException if some property of the specified + * @throws std::invalid_argument if some property of the specified * element prevents it from being added to this queue */ virtual bool offer(const E& value) = 0; @@ -98,11 +97,11 @@ namespace util /** * Gets and removes the element in the head of the queue. Throws a - * NoSuchElementException if there is no element in the queue. + * std::runtime_error if there is no element in the queue. * * @return the element in the head of the queue. * - * @throws NoSuchElementException + * @throws std::runtime_error * if there is no element in the queue. */ virtual E remove() = 0; @@ -122,11 +121,11 @@ namespace util /** * Gets but not removes the element in the head of the queue. Throws a - * NoSuchElementException if there is no element in the queue. + * std::runtime_error if there is no element in the queue. * * @return the element in the head of the queue. * - * @throws NoSuchElementException if there is no element in the queue. + * @throws std::runtime_error if there is no element in the queue. */ virtual E element() const = 0; diff --git a/activemq-cpp/src/main/decaf/util/Random.cpp b/activemq-cpp/src/main/decaf/util/Random.cpp index a9e1006a3..da1797d27 100644 --- a/activemq-cpp/src/main/decaf/util/Random.cpp +++ b/activemq-cpp/src/main/decaf/util/Random.cpp @@ -19,13 +19,13 @@ #include -#include -#include +#include +#include +#include using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; unsigned long long Random::multiplier = 0x5deece66dLL; @@ -70,8 +70,6 @@ void Random::nextBytes(std::vector& buf) this->nextBytes(&buf[0], (int)buf.size()); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCHALL_THROW(Exception) } @@ -80,16 +78,17 @@ void Random::nextBytes(unsigned char* buf, int size) { if (buf == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed cannot be NULL."); } if (size < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Specified buffer size was negative."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Specified buffer size was negative."); } int rand = 0; @@ -181,9 +180,8 @@ int Random::nextInt(int n) return val; } - throw exceptions::IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Value passed cannot be less than or equal to zero."); } diff --git a/activemq-cpp/src/main/decaf/util/Random.h b/activemq-cpp/src/main/decaf/util/Random.h index d486c1252..6b56501d6 100644 --- a/activemq-cpp/src/main/decaf/util/Random.h +++ b/activemq-cpp/src/main/decaf/util/Random.h @@ -18,9 +18,9 @@ #ifndef _DECAF_UTIL_RANDOM_H_ #define _DECAF_UTIL_RANDOM_H_ -#include #include #include +#include #include namespace decaf @@ -145,7 +145,7 @@ namespace util * * @return the next pseudo random int value. * - * @throws IllegalArgumentException if n is less than or equal to zero. + * @throws std::invalid_argument if n is less than or equal to zero. */ int nextInt(int n); diff --git a/activemq-cpp/src/main/decaf/util/Set.h b/activemq-cpp/src/main/decaf/util/Set.h index ae0724f87..4ade6313a 100644 --- a/activemq-cpp/src/main/decaf/util/Set.h +++ b/activemq-cpp/src/main/decaf/util/Set.h @@ -1,61 +1,61 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DECAF_UTIL_SET_H_ -#define _DECAF_UTIL_SET_H_ - -#include -#include -#include -#include -#include - -namespace decaf -{ -namespace util -{ - - /** - * A collection that contains no duplicate elements. More formally, sets - * contain no pair of elements e1 and e2 such that e1 == e2, and at most one - * null element. As implied by its name, this interface models the - * mathematical set abstraction. - * - * The additional stipulation on constructors is, not surprisingly, that all - * constructors must create a set that contains no duplicate elements (as - * defined above). - * - * Note: Great care must be exercised if mutable objects are used as set - * elements. The behavior of a set is not specified if the value of an - * object is changed in a manner that affects equals comparisons while the - * object is an element in the set. - * - * @since 1.0 - */ - template - class Set : public virtual decaf::util::Collection - { - public: - virtual ~Set() - { - } - }; - -} // namespace util -} // namespace decaf - -#endif /*_DECAF_UTIL_SET_H_*/ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _DECAF_UTIL_SET_H_ +#define _DECAF_UTIL_SET_H_ + +#include +#include +#include +#include +#include + +namespace decaf +{ +namespace util +{ + + /** + * A collection that contains no duplicate elements. More formally, sets + * contain no pair of elements e1 and e2 such that e1 == e2, and at most one + * null element. As implied by its name, this interface models the + * mathematical set abstraction. + * + * The additional stipulation on constructors is, not surprisingly, that all + * constructors must create a set that contains no duplicate elements (as + * defined above). + * + * Note: Great care must be exercised if mutable objects are used as set + * elements. The behavior of a set is not specified if the value of an + * object is changed in a manner that affects equals comparisons while the + * object is an element in the set. + * + * @since 1.0 + */ + template + class Set : public virtual decaf::util::Collection + { + public: + virtual ~Set() + { + } + }; + +} // namespace util +} // namespace decaf + +#endif /*_DECAF_UTIL_SET_H_*/ diff --git a/activemq-cpp/src/main/decaf/util/StlList.h b/activemq-cpp/src/main/decaf/util/StlList.h index baf39b320..7709e9697 100644 --- a/activemq-cpp/src/main/decaf/util/StlList.h +++ b/activemq-cpp/src/main/decaf/util/StlList.h @@ -18,17 +18,17 @@ #ifndef _DECAF_UTIL_STLLIST_H_ #define _DECAF_UTIL_STLLIST_H_ -#include -#include +#include #include #include #include #include #include -#include #include #include #include +#include +#include namespace decaf { @@ -81,9 +81,7 @@ namespace util { if (this->current == list->end()) { - throw NoSuchElementException( - __FILE__, - __LINE__, + throw activemq::exceptions::NoSuchElementException( "List::Iterator::next - No more elements to return"); } @@ -100,7 +98,7 @@ namespace util { if (this->prev == list->end()) { - throw lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "List::Iterator::remove - Invalid State to call " @@ -137,9 +135,7 @@ namespace util { if (this->current == this->list->begin()) { - throw NoSuchElementException( - __FILE__, - __LINE__, + throw activemq::exceptions::NoSuchElementException( "List::ListIterator::previous - No Previous element."); } @@ -205,9 +201,7 @@ namespace util { if (this->current == list->end()) { - throw NoSuchElementException( - __FILE__, - __LINE__, + throw activemq::exceptions::NoSuchElementException( "List::Iterator::next - No more elements to return"); } @@ -222,7 +216,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "List::ListIterator::remove - Const Iterator."); @@ -230,7 +224,7 @@ namespace util virtual void add(const E& e DECAF_UNUSED) { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "List::ListIterator::add - Const Iterator."); @@ -238,7 +232,7 @@ namespace util virtual void set(const E& e DECAF_UNUSED) { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "List::ListIterator::set - Const Iterator."); @@ -253,9 +247,7 @@ namespace util { if (this->current == this->list->begin()) { - throw NoSuchElementException( - __FILE__, - __LINE__, + throw activemq::exceptions::NoSuchElementException( "List::ListIterator::previous - No Previous element."); } @@ -388,9 +380,9 @@ namespace util { if (index < 0 || index > this->size()) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "List::listIterator - Index greater than size() or " "negative"); } @@ -402,9 +394,9 @@ namespace util { if (index < 0 || index > this->size()) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "List::listIterator - Index greater than size() or " "negative"); } @@ -443,10 +435,9 @@ namespace util { if (index < 0 || index >= this->size()) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "List::get - Index greater than size() or negative"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "List::get - Index greater than size() or negative"); } // Advance from begin and return the value at that location. @@ -462,10 +453,9 @@ namespace util { if (index < 0 || index >= this->size()) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "List::get - Index greater than size() or negative"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "List::get - Index greater than size() or negative"); } // Advance from begin and return the value at that location @@ -482,10 +472,9 @@ namespace util { if (index < 0 || index > this->size()) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "List::add - Index greater than size()"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "List::add - Index greater than size()"); } // Advance from begin and insert the value at that location @@ -525,10 +514,9 @@ namespace util { if (index < 0 || index > this->size()) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "List::addAll - Index greater than size()"); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "List::addAll - Index greater than size()"); } if (collection.isEmpty()) @@ -560,9 +548,9 @@ namespace util { if (index < 0 || index >= this->size()) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "List::removeAt - Index greater than size() or negative"); } diff --git a/activemq-cpp/src/main/decaf/util/StlMap.h b/activemq-cpp/src/main/decaf/util/StlMap.h index 9d0497c53..eee189e51 100644 --- a/activemq-cpp/src/main/decaf/util/StlMap.h +++ b/activemq-cpp/src/main/decaf/util/StlMap.h @@ -15,24 +15,24 @@ * limitations under the License. */ +#include #ifndef _DECAF_UTIL_STLMAP_H_ #define _DECAF_UTIL_STLMAP_H_ #include -#include #include #include #include -#include #include #include -#include #include #include #include #include #include #include +#include +#include namespace decaf { @@ -98,7 +98,7 @@ namespace util { if (expectedModCount != this->associatedMap->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "StlMap modified outside this iterator"); @@ -111,9 +111,10 @@ namespace util if (!checkHasNext()) { - throw NoSuchElementException(__FILE__, - __LINE__, - "No next element"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "No next element"); } currentEntry = futureEntry; @@ -126,10 +127,11 @@ namespace util if (currentEntry == this->associatedMap->valueMap.end()) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "Remove called before call to next()"); + "Remove called before call to " + "next()"); } this->associatedMap->valueMap.erase(currentEntry); @@ -283,7 +285,7 @@ namespace util { if (expectedModCount != this->associatedMap->modCount) { - throw ConcurrentModificationException( + throw activemq::exceptions::ConcurrentModificationException( __FILE__, __LINE__, "StlMap modified outside this iterator"); @@ -296,9 +298,10 @@ namespace util if (!checkHasNext()) { - throw NoSuchElementException(__FILE__, - __LINE__, - "No next element"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "No next element"); } currentEntry = futureEntry; @@ -337,7 +340,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -374,7 +377,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -411,7 +414,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -513,7 +516,7 @@ namespace util virtual void clear() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't clear a const collection"); @@ -521,7 +524,7 @@ namespace util virtual bool remove(const MapEntry& entry DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't remove from const collection"); @@ -540,7 +543,7 @@ namespace util virtual Iterator>* iterator() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't return a non-const iterator for a const collection"); @@ -641,7 +644,7 @@ namespace util virtual void clear() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't modify a const collection"); @@ -649,7 +652,7 @@ namespace util virtual bool remove(const K& key DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't modify a const collection"); @@ -657,7 +660,7 @@ namespace util virtual Iterator* iterator() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't return a non-const iterator for a const collection"); @@ -749,7 +752,7 @@ namespace util virtual void clear() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't modify a const collection"); @@ -757,7 +760,7 @@ namespace util virtual Iterator* iterator() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't return a non-const iterator for a const collection"); @@ -969,9 +972,10 @@ namespace util iter = valueMap.find(key); if (iter == valueMap.end()) { - throw NoSuchElementException(__FILE__, - __LINE__, - "Key does not exist in map"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "Key does not exist in map"); } return iter->second; @@ -986,9 +990,10 @@ namespace util iter = valueMap.find(key); if (iter == valueMap.end()) { - throw NoSuchElementException(__FILE__, - __LINE__, - "Key does not exist in map"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "Key does not exist in map"); } return iter->second; @@ -1057,9 +1062,10 @@ namespace util valueMap.find(key); if (iter == valueMap.end()) { - throw NoSuchElementException(__FILE__, - __LINE__, - "Key is not present in this Map."); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "Key is not present in this Map."); } V result = iter->second; diff --git a/activemq-cpp/src/main/decaf/util/StlQueue.h b/activemq-cpp/src/main/decaf/util/StlQueue.h index 8f2d47373..3be34c670 100644 --- a/activemq-cpp/src/main/decaf/util/StlQueue.h +++ b/activemq-cpp/src/main/decaf/util/StlQueue.h @@ -17,10 +17,13 @@ #ifndef _DECAF_UTIL_STLQUEUE_H_ #define _DECAF_UTIL_STLQUEUE_H_ +#include #include #include #include #include +#include +#include #include namespace decaf @@ -92,7 +95,7 @@ namespace util { if (this->current == queue->end()) { - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "Queue::Iterator::next - No more elements to return"); @@ -111,7 +114,7 @@ namespace util { if (this->previous == queue->end()) { - throw lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Queue::Iterator::remove - Invalid State to call " diff --git a/activemq-cpp/src/main/decaf/util/StlSet.h b/activemq-cpp/src/main/decaf/util/StlSet.h index de858c077..1b660b6e6 100644 --- a/activemq-cpp/src/main/decaf/util/StlSet.h +++ b/activemq-cpp/src/main/decaf/util/StlSet.h @@ -18,13 +18,15 @@ #ifndef _DECAF_UTIL_STLSET_H_ #define _DECAF_UTIL_STLSET_H_ +#include #include #include -#include #include #include #include #include +#include +#include #include namespace decaf @@ -72,7 +74,7 @@ namespace util { if (this->current == set->end()) { - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "Set::Iterator::next - No more elements to return"); @@ -91,7 +93,7 @@ namespace util { if (this->previous == set->end()) { - throw lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Set::Iterator::remove - Invalid State to call remove"); @@ -130,7 +132,7 @@ namespace util { if (this->current == set->end()) { - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "Set::Iterator::next - No more elements to return"); @@ -147,7 +149,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Set::Iterator::remove - Not Valid on a Const Iterator"); diff --git a/activemq-cpp/src/main/decaf/util/StringTokenizer.cpp b/activemq-cpp/src/main/decaf/util/StringTokenizer.cpp index 063175f3d..cce7e2770 100644 --- a/activemq-cpp/src/main/decaf/util/StringTokenizer.cpp +++ b/activemq-cpp/src/main/decaf/util/StringTokenizer.cpp @@ -16,13 +16,12 @@ */ #include "StringTokenizer.h" -#include +#include +#include using namespace std; using namespace decaf; using namespace decaf::util; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// StringTokenizer::StringTokenizer(const std::string& str, @@ -86,9 +85,7 @@ std::string StringTokenizer::nextToken() { if (pos == string::npos) { - throw NoSuchElementException( - __FILE__, - __LINE__, + throw activemq::exceptions::NoSuchElementException( "StringTokenizer::nextToken - No more Tokens available"); } @@ -118,9 +115,7 @@ std::string StringTokenizer::nextToken() } else { - throw NoSuchElementException( - __FILE__, - __LINE__, + throw activemq::exceptions::NoSuchElementException( "StringTokenizer::nextToken - No more Tokens available"); } } diff --git a/activemq-cpp/src/main/decaf/util/StringTokenizer.h b/activemq-cpp/src/main/decaf/util/StringTokenizer.h index 7ada08206..5bf4a0e00 100644 --- a/activemq-cpp/src/main/decaf/util/StringTokenizer.h +++ b/activemq-cpp/src/main/decaf/util/StringTokenizer.h @@ -18,7 +18,7 @@ #define _DECAF_UTIL_STRINGTOKENIZER_H_ #include -#include +#include #include #include @@ -92,7 +92,7 @@ namespace util * * @return string value of next token * - * @throws NoSuchElementException if there are no more tokens in this + * @throws std::runtime_error if there are no more tokens in this * string. */ virtual std::string nextToken(); @@ -111,7 +111,7 @@ namespace util * * @return next string in the token list * - * @throws NoSuchElementException if there are no more tokens in this + * @throws std::runtime_error if there are no more tokens in this * string. */ virtual std::string nextToken(const std::string& delim); diff --git a/activemq-cpp/src/main/decaf/util/Timer.cpp b/activemq-cpp/src/main/decaf/util/Timer.cpp index c795e99d0..26c2da47d 100644 --- a/activemq-cpp/src/main/decaf/util/Timer.cpp +++ b/activemq-cpp/src/main/decaf/util/Timer.cpp @@ -17,13 +17,15 @@ #include "Timer.h" +#include #include #include #include #include #include -#include #include +#include +#include using namespace decaf; using namespace decaf::util; @@ -32,7 +34,6 @@ using namespace decaf::internal; using namespace decaf::internal::util; using namespace decaf::internal::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace decaf @@ -95,7 +96,7 @@ namespace util { this->wait(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { } } @@ -136,7 +137,7 @@ namespace util { this->wait(timeToSleep); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { } // Check if cancelled while waiting @@ -336,10 +337,10 @@ void Timer::schedule(TimerTask* task, long long delay) { if (delay < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Task must be scheduled to start in the " - "Future but delay was Negative"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Task must be scheduled to start in the " + "Future but delay was Negative"); } Pointer wrapper(task); @@ -354,6 +355,11 @@ void Timer::schedule(TimerTask* task, long long delay) ex.setMark(__FILE__, __LINE__); throw; } + catch (std::exception&) + { + wrapper.release(); + throw; + } } //////////////////////////////////////////////////////////////////////////////// @@ -361,10 +367,10 @@ void Timer::schedule(const Pointer& task, long long delay) { if (delay < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Task must be scheduled to start in the " - "Future but delay was Negative"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Task must be scheduled to start in the " + "Future but delay was Negative"); } scheduleTask(task, delay, -1, false); @@ -375,9 +381,8 @@ void Timer::schedule(TimerTask* task, const Date& when) { if (when.getTime() < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled to start in the Future."); } @@ -394,6 +399,11 @@ void Timer::schedule(TimerTask* task, const Date& when) ex.setMark(__FILE__, __LINE__); throw; } + catch (std::exception&) + { + wrapper.release(); + throw; + } } //////////////////////////////////////////////////////////////////////////////// @@ -401,9 +411,8 @@ void Timer::schedule(const Pointer& task, const Date& when) { if (when.getTime() < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled to start in the Future."); } @@ -416,17 +425,16 @@ void Timer::schedule(TimerTask* task, long long delay, long long period) { if (delay < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Task must be scheduled to start in the " - "Future but delay was Negative"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Task must be scheduled to start in the " + "Future but delay was Negative"); } if (period <= 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled non-negative or non-zero period."); } @@ -442,6 +450,11 @@ void Timer::schedule(TimerTask* task, long long delay, long long period) ex.setMark(__FILE__, __LINE__); throw; } + catch (std::exception&) + { + wrapper.release(); + throw; + } } //////////////////////////////////////////////////////////////////////////////// @@ -451,17 +464,16 @@ void Timer::schedule(const Pointer& task, { if (delay < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Task must be scheduled to start in the " - "Future but delay was Negative"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Task must be scheduled to start in the " + "Future but delay was Negative"); } if (period <= 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled non-negative or non-zero period."); } @@ -473,17 +485,15 @@ void Timer::schedule(TimerTask* task, const Date& when, long long period) { if (when.getTime() < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled to start in the Future."); } if (period <= 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled non-negative or non-zero period."); } @@ -500,6 +510,11 @@ void Timer::schedule(TimerTask* task, const Date& when, long long period) ex.setMark(__FILE__, __LINE__); throw; } + catch (std::exception&) + { + wrapper.release(); + throw; + } } //////////////////////////////////////////////////////////////////////////////// @@ -509,17 +524,15 @@ void Timer::schedule(const Pointer& task, { if (when.getTime() < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled to start in the Future."); } if (period <= 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled non-negative or non-zero period."); } @@ -534,17 +547,16 @@ void Timer::scheduleAtFixedRate(TimerTask* task, { if (delay < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Task must be scheduled to start in the " - "Future but delay was Negative"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Task must be scheduled to start in the " + "Future but delay was Negative"); } if (period <= 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled non-negative or non-zero period."); } @@ -560,6 +572,11 @@ void Timer::scheduleAtFixedRate(TimerTask* task, ex.setMark(__FILE__, __LINE__); throw; } + catch (std::exception&) + { + wrapper.release(); + throw; + } } //////////////////////////////////////////////////////////////////////////////// @@ -569,17 +586,16 @@ void Timer::scheduleAtFixedRate(const Pointer& task, { if (delay < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Task must be scheduled to start in the " - "Future but delay was Negative"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Task must be scheduled to start in the " + "Future but delay was Negative"); } if (period <= 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled non-negative or non-zero period."); } @@ -593,17 +609,15 @@ void Timer::scheduleAtFixedRate(TimerTask* task, { if (when.getTime() < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled to start in the Future."); } if (period <= 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled non-negative or non-zero period."); } @@ -620,6 +634,11 @@ void Timer::scheduleAtFixedRate(TimerTask* task, ex.setMark(__FILE__, __LINE__); throw; } + catch (std::exception&) + { + wrapper.release(); + throw; + } } //////////////////////////////////////////////////////////////////////////////// @@ -629,17 +648,15 @@ void Timer::scheduleAtFixedRate(const Pointer& task, { if (when.getTime() < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled to start in the Future."); } if (period <= 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Task must be scheduled non-negative or non-zero period."); } @@ -655,46 +672,50 @@ void Timer::scheduleTask(const Pointer& task, { if (task == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Task pointer passed in was Null"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Task pointer passed in was Null"); } synchronized(this->internal) { if (this->internal->cancelled) { - throw IllegalStateException(__FILE__, - __LINE__, - "Timer was cancelled."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Timer was cancelled."); } long long when = delay + System::currentTimeMillis(); if (when < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Task must be scheduled to start in " - "the Future but delay was Negative"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Task must be scheduled to start in " + "the Future but delay was Negative"); } synchronized(&(task->lock)) { if (task->isScheduled()) { - throw IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "Task is already scheduled in a Timer, cannot add again."); + "Task is already scheduled in a Timer, " + "cannot add again."); } if (task->cancelled) { - throw IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "Task is already has been cancelled cannot be restarted."); + "Task is already has been cancelled " + "cannot be restarted."); } task->when = when; diff --git a/activemq-cpp/src/main/decaf/util/Timer.h b/activemq-cpp/src/main/decaf/util/Timer.h index 634686199..aed76ed8d 100644 --- a/activemq-cpp/src/main/decaf/util/Timer.h +++ b/activemq-cpp/src/main/decaf/util/Timer.h @@ -21,12 +21,10 @@ #include #include -#include -#include -#include #include #include #include +#include namespace decaf { @@ -110,7 +108,7 @@ namespace util * * @return true if the Timer terminated or false if the timeout expired. * - * @throws InterruptedException if this call is interrupted while + * @throws std::runtime_error if this call is interrupted while * awaiting termination. */ bool awaitTermination(long long timeout, @@ -153,10 +151,10 @@ namespace util * @param task - task to be scheduled. * @param delay - delay in milliseconds before task is to be executed. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if delay is negative, or delay + + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if delay is negative, or delay + * System.currentTimeMillis() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if task was already scheduled or * canceled, or timer was canceled. */ void schedule(TimerTask* task, long long delay); @@ -167,10 +165,10 @@ namespace util * @param task - task to be scheduled. * @param delay - delay in milliseconds before task is to be executed. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if delay is negative, or delay + + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if delay is negative, or delay + * System.currentTimeMillis() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if task was already scheduled or * canceled, or timer was canceled. */ void schedule(const decaf::lang::Pointer& task, @@ -194,9 +192,9 @@ namespace util * @param task - task to be scheduled. * @param time - time at which task is to be executed. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if time.getTime() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if time.getTime() is negative. + * @throw std::logic_error - if task was already scheduled or * canceled, timer was canceled, or timer thread terminated. */ void schedule(TimerTask* task, const Date& time); @@ -209,9 +207,9 @@ namespace util * @param task - task to be scheduled. * @param time - time at which task is to be executed. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if time.getTime() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if time.getTime() is negative. + * @throw std::logic_error - if task was already scheduled or * canceled, timer was canceled, or timer thread terminated. */ void schedule(const decaf::lang::Pointer& task, @@ -254,10 +252,10 @@ namespace util * @param period - time in milliseconds between successive task * executions. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if delay is negative, or delay + + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if delay is negative, or delay + * System.currentTimeMillis() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if task was already scheduled or * canceled, timer was canceled, or timer thread terminated. */ void schedule(TimerTask* task, long long delay, long long period); @@ -289,10 +287,10 @@ namespace util * @param period - time in milliseconds between successive task * executions. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if delay is negative, or delay + + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if delay is negative, or delay + * System.currentTimeMillis() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if task was already scheduled or * canceled, timer was canceled, or timer thread terminated. */ void schedule(const decaf::lang::Pointer& task, @@ -336,9 +334,9 @@ namespace util * @param period - time in milliseconds between successive task * executions. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if time.getTime() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if time.getTime() is negative. + * @throw std::logic_error - if task was already scheduled or * canceled, timer was canceled, or timer thread terminated. */ void schedule(TimerTask* task, const Date& firstTime, long long period); @@ -370,9 +368,9 @@ namespace util * @param period - time in milliseconds between successive task * executions. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if time.getTime() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if time.getTime() is negative. + * @throw std::logic_error - if task was already scheduled or * canceled, timer was canceled, or timer thread terminated. */ void schedule(const decaf::lang::Pointer& task, @@ -418,10 +416,10 @@ namespace util * @param period - time in milliseconds between successive task * executions. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if delay is negative, or delay + + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if delay is negative, or delay + * System.currentTimeMillis() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if task was already scheduled or * canceled, timer was canceled, or timer thread terminated. */ void scheduleAtFixedRate(TimerTask* task, @@ -457,10 +455,10 @@ namespace util * @param period - time in milliseconds between successive task * executions. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if delay is negative, or delay + + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if delay is negative, or delay + * System.currentTimeMillis() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if task was already scheduled or * canceled, timer was canceled, or timer thread terminated. */ void scheduleAtFixedRate(const decaf::lang::Pointer& task, @@ -505,9 +503,9 @@ namespace util * @param period - time in milliseconds between successive task * executions. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if time.getTime() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if time.getTime() is negative. + * @throw std::logic_error - if task was already scheduled or * canceled, timer was canceled, or timer thread terminated. */ void scheduleAtFixedRate(TimerTask* task, @@ -542,9 +540,9 @@ namespace util * @param period - time in milliseconds between successive task * executions. * - * @throw NullPointerException - if the TimerTask value is Null. - * @throw IllegalArgumentException - if time.getTime() is negative. - * @throw IllegalStateException - if task was already scheduled or + * @throw std::logic_error - if the TimerTask value is Null. + * @throws std::invalid_argument - if time.getTime() is negative. + * @throw std::logic_error - if task was already scheduled or * canceled, timer was canceled, or timer thread terminated. */ void scheduleAtFixedRate(const decaf::lang::Pointer& task, diff --git a/activemq-cpp/src/main/decaf/util/UUID.cpp b/activemq-cpp/src/main/decaf/util/UUID.cpp index 60c79805f..f38d4a9de 100644 --- a/activemq-cpp/src/main/decaf/util/UUID.cpp +++ b/activemq-cpp/src/main/decaf/util/UUID.cpp @@ -21,21 +21,22 @@ #include #endif #include +#include #include #include -#include -#include -#include #include #include #include +#include +#include +#include + using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::internal::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::security; //////////////////////////////////////////////////////////////////////////////// @@ -250,7 +251,7 @@ long long UUID::node() { if (this->version() != 1) { - throw exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "UUID::node - Only a Version 1 UUID supports this operation."); @@ -264,7 +265,7 @@ long long UUID::timestamp() { if (this->version() != 1) { - throw exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "UUID::node - Only a Version 1 UUID supports this operation."); @@ -283,7 +284,7 @@ int UUID::clockSequence() { if (this->version() != 1) { - throw exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "UUID::node - Only a Version 1 UUID supports this operation."); @@ -368,9 +369,10 @@ UUID UUID::nameUUIDFromBytes(const char* name, int size) { if (name == NULL && size > 0) { - throw NullPointerException(__FILE__, - __LINE__, - "UUID name buffer was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "UUID name buffer was NULL"); } std::vector hash; @@ -382,7 +384,7 @@ UUID UUID::nameUUIDFromBytes(const char* name, int size) } catch (NoSuchAlgorithmException& ex) { - throw exceptions::RuntimeException( + throw activemq::exceptions::RuntimeException( __FILE__, __LINE__, "UUID::nameUUIDFromBytes - Failed to run MD5 encoder."); @@ -434,39 +436,34 @@ UUID UUID::fromString(const std::string& uuid) // should have and only can have four "-" in UUID if (i != POS_SIZE || lastPosition != -1) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Invalid UUID string %s", - uuid.c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": Invalid UUID string " + uuid); } if (position[0] == 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Invalid UUID string %s", - uuid.c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": Invalid UUID string " + uuid); } else if (((position[1] - position[0]) - 1) <= 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Invalid UUID string %s", - uuid.c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": Invalid UUID string " + uuid); } else if (((position[2] - position[1]) - 1) <= 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Invalid UUID string %s", - uuid.c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": Invalid UUID string " + uuid); } else if ((position[3] + 1) >= (int)uuid.length()) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Invalid UUID string %s", - uuid.c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": Invalid UUID string " + uuid); } long long m1 = Long::parseLong(uuid.substr(0, position[0]), 16); diff --git a/activemq-cpp/src/main/decaf/util/UUID.h b/activemq-cpp/src/main/decaf/util/UUID.h index 0f35b3ef8..8ade9b507 100644 --- a/activemq-cpp/src/main/decaf/util/UUID.h +++ b/activemq-cpp/src/main/decaf/util/UUID.h @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -101,6 +102,9 @@ namespace util * The size of the byte array, or number of bytes to use. * * @return type 3 UUID + * + * @throws std::logic_error if name is NULL but size is greater than + * zero. */ static UUID nameUUIDFromBytes(const char* name, int size); @@ -113,7 +117,7 @@ namespace util * * @return type 3 UUID * - * @throws IllegalArgumentException if the UUID string given is invalid. + * @throws std::invalid_argument if the UUID string given is invalid. */ static UUID fromString(const std::string& name); @@ -234,7 +238,7 @@ namespace util * * @return the node value of this UUID * - * @throws UnsupportedOperationException if this UUID version does not + * @throws std::logic_error if this UUID version does not * support this operation. */ long long node(); @@ -253,7 +257,7 @@ namespace util * * @return the timestamp associated with a V1 UUID * - * @throws UnsupportedOperationException if this UUID version does not + * @throws std::logic_error if this UUID version does not * support this operation. */ long long timestamp(); @@ -271,7 +275,7 @@ namespace util * * @return the clockSequeunce associated with a V1 UUID * - * @throws UnsupportedOperationException if this UUID version does not + * @throws std::logic_error if this UUID version does not * support this operation. */ int clockSequence(); @@ -288,7 +292,7 @@ namespace util * * @return the variant associated with a V1 UUID * - * @throws UnsupportedOperationException if this UUID version does not + * @throws std::logic_error if this UUID version does not * support this operation. */ int variant(); @@ -305,7 +309,7 @@ namespace util * * @return the version associated with a V1 UUID * - * @throws UnsupportedOperationException if this UUID version does not + * @throws std::logic_error if this UUID version does not * support this operation. */ int version(); diff --git a/activemq-cpp/src/main/decaf/util/concurrent/AbstractExecutorService.cpp b/activemq-cpp/src/main/decaf/util/concurrent/AbstractExecutorService.cpp index 35e7cc2cf..6ebde204b 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/AbstractExecutorService.cpp +++ b/activemq-cpp/src/main/decaf/util/concurrent/AbstractExecutorService.cpp @@ -17,13 +17,14 @@ #include "AbstractExecutorService.h" -#include +#include +#include +#include using namespace decaf; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// AbstractExecutorService::AbstractExecutorService() @@ -45,15 +46,18 @@ void AbstractExecutorService::doSubmit(FutureType* future) Runnable* task = dynamic_cast(future); if (task == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, - "Could not cast FutureType to a Runnabke"); + "Could not cast FutureType to a Runnable"); } // Ensure that we tell the subclass it owns the Future. this->execute(task, true); } - DECAF_CATCH_RETHROW(NullPointerException) + catch (activemq::exceptions::NullPointerException&) + { + throw; + } DECAF_CATCH_RETHROW(RejectedExecutionException) } diff --git a/activemq-cpp/src/main/decaf/util/concurrent/BlockingQueue.h b/activemq-cpp/src/main/decaf/util/concurrent/BlockingQueue.h index 8151e132d..f5f334104 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/BlockingQueue.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/BlockingQueue.h @@ -21,8 +21,8 @@ #include #include -#include #include +#include namespace decaf { @@ -125,7 +125,7 @@ namespace util * virtual void run() { * try { * while( true ) { queue->put( produce() ); } - * } catch( InterruptedException& ex ) { ... handle ...} + * } catch( std::runtime_error& ex ) { ... handle ...} * } * * Object produce() { ... } @@ -143,7 +143,7 @@ namespace util * virtual void run() { * try { * while( true ) { consume( queue->take() ); } - * } catch( InterruptedException& ex ) { ... handle ...} + * } catch( std::runtime_error& ex ) { ... handle ...} * } * * void consume( Object& x ) { ... } @@ -184,9 +184,9 @@ namespace util * necessary for space to become available. * * @param value the element to add - * @throws InterruptedException if interrupted while waiting - * @throws NullPointerException if the specified element is null - * @throws IllegalArgumentException if some property of the + * @throws std::runtime_error if interrupted while waiting + * @throws std::logic_error if the specified element is null + * @throws std::invalid_argument if some property of the * specified element prevents it from being added to this queue */ virtual void put(const E& value) = 0; @@ -205,9 +205,9 @@ namespace util * the specified waiting time elapses before space is * available * - * @throws InterruptedException if interrupted while waiting - * @throws NullPointerException if the specified element is null - * @throws IllegalArgumentException if some property of the + * @throws std::runtime_error if interrupted while waiting + * @throws std::logic_error if the specified element is null + * @throws std::invalid_argument if some property of the * specified element prevents it from being added to this queue */ virtual bool offer(const E& e, @@ -219,7 +219,7 @@ namespace util * necessary until an element becomes available. * * @return the head of this queue - * @throws InterruptedException if interrupted while waiting + * @throws std::runtime_error if interrupted while waiting */ virtual E take() = 0; @@ -237,7 +237,7 @@ namespace util * timeout parameter. * @return true if successful or false if the * specified waiting time elapses before an element is available. - * @throws InterruptedException if interrupted while waiting + * @throws std::runtime_error if interrupted while waiting */ virtual bool poll(E& result, long long timeout, @@ -265,15 +265,15 @@ namespace util * attempting to add elements to collection c may result in * elements being in neither, either or both collections when the * associated exception is thrown. Attempts to drain a queue to - * itself result in IllegalArgumentException. Further, the + * itself result in std::invalid_argument. Further, the * behavior of this operation is undefined if the specified * collection is modified while the operation is in progress. * * @param c the collection to transfer elements into * @return the number of elements transferred - * @throws UnsupportedOperationException if addition of elements + * @throws std::logic_error if addition of elements * is not supported by the specified collection - * @throws IllegalArgumentException if the specified collection is + * @throws std::invalid_argument if the specified collection is * this queue, or some property of an element of this queue prevents * it from being added to the specified collection */ @@ -286,16 +286,16 @@ namespace util * collection c may result in elements being in neither, * either or both collections when the associated exception is * thrown. Attempts to drain a queue to itself result in - * IllegalArgumentException. Further, the behavior of + * std::invalid_argument. Further, the behavior of * this operation is undefined if the specified collection is * modified while the operation is in progress. * * @param c the collection to transfer elements into * @param maxElements the maximum number of elements to transfer * @return the number of elements transferred - * @throws UnsupportedOperationException if addition of elements + * @throws std::logic_error if addition of elements * is not supported by the specified collection - * @throws IllegalArgumentException if the specified collection is + * @throws std::invalid_argument if the specified collection is * this queue, or some property of an element of this queue prevents * it from being added to the specified collection */ diff --git a/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentMap.h b/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentMap.h index 071691790..639455190 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentMap.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentMap.h @@ -21,9 +21,7 @@ #include #include -#include -#include -#include +#include namespace decaf { @@ -64,7 +62,7 @@ namespace util * @return true if the put operation was performed otherwise return * false which indicates there was a value previously mapped to the * key. - * @throw UnsupportedOperationException + * @throws std::logic_error * if the put operation is not supported by this map */ virtual bool putIfAbsent(const K& key, const V& value) = 0; @@ -117,7 +115,7 @@ namespace util * if( ( map.containsKey( key ) ) { * return map.put( key, value ); * } else { - * throw NoSuchElementException(...); + * throw std::runtime_error(...); * }; * * except that the action is performed atomically. @@ -126,10 +124,10 @@ namespace util * @param value value to be associated with the specified key. * * @return copy of the previous value associated with specified key, - * or throws an NoSuchElementException if there was no mapping for + * or throws an std::runtime_error if there was no mapping for * key. * - * @throws NoSuchElementException if there was no previous mapping. + * @throws std::runtime_error if there was no previous mapping. */ virtual V replace(const K& key, const V& value) = 0; diff --git a/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h b/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h index df9bbb8a5..df210cd58 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h @@ -15,20 +15,21 @@ * limitations under the License. */ +#include #ifndef _DECAF_UTIL_CONCURRENTSTLMAP_H_ #define _DECAF_UTIL_CONCURRENTSTLMAP_H_ #include #include #include -#include #include #include -#include #include #include #include #include +#include +#include #include namespace decaf @@ -104,10 +105,11 @@ namespace util { if (expectedModCount != this->associatedMap->modCount) { - throw ConcurrentModificationException( - __FILE__, - __LINE__, - "StlMap modified outside this iterator"); + throw activemq::exceptions:: + ConcurrentModificationException( + __FILE__, + __LINE__, + "StlMap modified outside this iterator"); } } @@ -119,9 +121,10 @@ namespace util if (!checkHasNext()) { - throw NoSuchElementException(__FILE__, - __LINE__, - "No next element"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "No next element"); } currentEntry = futureEntry; @@ -137,10 +140,11 @@ namespace util if (currentEntry == this->associatedMap->valueMap.end()) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "Remove called before call to next()"); + "Remove called before call " + "to next()"); } this->associatedMap->valueMap.erase(currentEntry); @@ -316,10 +320,11 @@ namespace util { if (expectedModCount != this->associatedMap->modCount) { - throw ConcurrentModificationException( - __FILE__, - __LINE__, - "StlMap modified outside this iterator"); + throw activemq::exceptions:: + ConcurrentModificationException( + __FILE__, + __LINE__, + "StlMap modified outside this iterator"); } } } @@ -332,9 +337,10 @@ namespace util if (!checkHasNext()) { - throw NoSuchElementException(__FILE__, - __LINE__, - "No next element"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "No next element"); } currentEntry = futureEntry; @@ -379,7 +385,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -421,7 +427,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -463,7 +469,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const Iterator."); @@ -571,7 +577,7 @@ namespace util virtual void clear() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't clear a const collection"); @@ -579,7 +585,7 @@ namespace util virtual bool remove(const MapEntry& entry DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't remove from const collection"); @@ -601,7 +607,7 @@ namespace util virtual Iterator>* iterator() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't return a non-const iterator for a const " @@ -706,7 +712,7 @@ namespace util virtual void clear() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't modify a const collection"); @@ -714,7 +720,7 @@ namespace util virtual bool remove(const K& key DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't modify a const collection"); @@ -722,7 +728,7 @@ namespace util virtual Iterator* iterator() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't return a non-const iterator for a const " @@ -815,7 +821,7 @@ namespace util virtual void clear() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't modify a const collection"); @@ -823,7 +829,7 @@ namespace util virtual Iterator* iterator() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Can't return a non-const iterator for a const " @@ -1072,9 +1078,10 @@ namespace util } } - throw NoSuchElementException(__FILE__, - __LINE__, - "Key does not exist in map"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "Key does not exist in map"); } /** @@ -1095,9 +1102,10 @@ namespace util } } - throw NoSuchElementException(__FILE__, - __LINE__, - "Key does not exist in map"); + throw activemq::exceptions::NoSuchElementException( + __FILE__, + __LINE__, + "Key does not exist in map"); } /** @@ -1210,7 +1218,7 @@ namespace util * @return true if the put operation was performed otherwise return * false which indicates there was a value previously mapped to the * key. - * @throw UnsupportedOperationException + * @throws activemq::exceptions::IllegalStateException * if the put operation is not supported by this map */ bool putIfAbsent(const K& key, const V& value) @@ -1300,7 +1308,8 @@ namespace util * if( map.containsKey( key ) ) { * return map.put( key, value ); * } else { - * throw NoSuchElementException(...); + * throw + * activemq::exceptions::InterruptedException(...); * }; * * except that the action is performed atomically. @@ -1309,10 +1318,11 @@ namespace util * @param value value to be associated with the specified key. * * @return copy of the previous value associated with specified key, - * or throws an NoSuchElementException if there was no mapping for - * key. + * or throws an activemq::exceptions::InterruptedException + * if there was no mapping for key. * - * @throws NoSuchElementException if there was no previous mapping. + * @throws activemq::exceptions::InterruptedException if + * there was no previous mapping. */ V replace(const K& key, const V& value) { @@ -1326,7 +1336,7 @@ namespace util } } - throw NoSuchElementException( + throw activemq::exceptions::NoSuchElementException( __FILE__, __LINE__, "Value to Replace was not in the Map."); diff --git a/activemq-cpp/src/main/decaf/util/concurrent/CopyOnWriteArrayList.h b/activemq-cpp/src/main/decaf/util/concurrent/CopyOnWriteArrayList.h index 7b695b2a5..1976d6b96 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/CopyOnWriteArrayList.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/CopyOnWriteArrayList.h @@ -15,17 +15,18 @@ * limitations under the License. */ +#include #ifndef _DECAF_UTIL_CONCURRENT_COPYONWRITEARRAYLIST_H_ #define _DECAF_UTIL_CONCURRENT_COPYONWRITEARRAYLIST_H_ #include #include #include -#include #include -#include #include #include +#include +#include namespace decaf { @@ -137,9 +138,9 @@ namespace util { if (position < 0 || position > array->size) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + "Iterator created with invalid index."); } } @@ -153,7 +154,7 @@ namespace util { if (position >= array->size) { - throw NoSuchElementException(); + throw activemq::exceptions::NoSuchElementException(); } return this->array->elements[position++]; @@ -166,7 +167,7 @@ namespace util virtual void remove() { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "CopyOnWriteArrayList Iterator cannot remove " @@ -175,18 +176,20 @@ namespace util virtual void add(const E& e DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, - "CopyOnWriteArrayList Iterator cannot add elements."); + "CopyOnWriteArrayList Iterator cannot add " + "elements."); } virtual void set(const E& e DECAF_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, - "CopyOnWriteArrayList Iterator cannot add elements."); + "CopyOnWriteArrayList Iterator cannot add " + "elements."); } virtual bool hasPrevious() const @@ -198,7 +201,7 @@ namespace util { if (position <= 0) { - throw NoSuchElementException(); + throw activemq::exceptions::NoSuchElementException(); } return this->array->elements[position--]; @@ -281,6 +284,11 @@ namespace util this->writeLock.unlock(); throw; } + catch (std::exception&) + { + this->writeLock.unlock(); + throw; + } this->arrayLock.writeLock().unlock(); return *this; @@ -299,6 +307,11 @@ namespace util this->writeLock.unlock(); throw; } + catch (std::exception&) + { + this->writeLock.unlock(); + throw; + } this->arrayLock.writeLock().unlock(); return *this; @@ -399,6 +412,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } for (int i = 0; i < current->size; ++i) { @@ -486,6 +504,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } return current->size == 0; } @@ -631,6 +654,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } return current->size; } @@ -649,6 +677,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } std::vector result((std::size_t)current->size); for (int i = 0; i < current->size; ++i) { @@ -673,6 +706,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } return new ArrayListIterator(current, 0); } @@ -691,6 +729,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } return new ArrayListIterator(current, 0); } @@ -710,6 +753,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } return new ArrayListIterator(current, 0); } @@ -728,6 +776,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } return new ArrayListIterator(current, 0); } @@ -746,6 +799,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } return new ArrayListIterator(current, index); } @@ -764,6 +822,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } return new ArrayListIterator(this->array, index); } @@ -782,6 +845,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } for (int i = 0; i < current->size; ++i) { @@ -808,6 +876,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } for (int i = current->size - 1; i >= 0; --i) { @@ -834,6 +907,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } checkIndexExclusive(index, current->size); return current->elements[index]; @@ -1015,6 +1093,11 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } std::string result; return result; @@ -1133,7 +1216,7 @@ namespace util * @return the index in the list that matches the value given, or -1 * if not found. * - * @throws IndexOutOfBoundsException if the given index is greater + * @throws std::out_of_range if the given index is greater * than or equal to the List size. */ int lastIndexOf(const E& value, int index) @@ -1150,15 +1233,18 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } if (index >= current->size) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index given %d, actual size %d", - index, - current->size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index given " + std::to_string(index) + + ", actual size " + std::to_string(current->size)); } for (int i = index - 1; i >= 0; --i) @@ -1185,7 +1271,7 @@ namespace util * @return the index in the List that matches the given element or * -1 if not found. * - * @throws IndexOutOfBoundsException if the given index is negative. + * @throws std::out_of_range if the given index is negative. */ int indexOf(const E& value, int index) const { @@ -1201,15 +1287,18 @@ namespace util this->arrayLock.readLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.readLock().unlock(); + throw; + } if (index < 0) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index given %d, actual size %d", - index, - current->size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index given " + std::to_string(index) + + ", actual size " + std::to_string(current->size)); } for (int i = index; i < current->size; ++i) @@ -1302,18 +1391,21 @@ namespace util this->arrayLock.writeLock().unlock(); throw; } + catch (std::exception&) + { + this->arrayLock.writeLock().unlock(); + throw; + } } static void checkIndexInclusive(int index, int size) { if (index < 0 || index > size) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index is %d, size is %d", - index, - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index is " + std::to_string(index) + + ", size is " + std::to_string(size)); } } @@ -1321,12 +1413,10 @@ namespace util { if (index < 0 || index >= size) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "Index is %d, size is %d", - index, - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Index is " + std::to_string(index) + + ", size is " + std::to_string(size)); } } }; diff --git a/activemq-cpp/src/main/decaf/util/concurrent/CopyOnWriteArraySet.h b/activemq-cpp/src/main/decaf/util/concurrent/CopyOnWriteArraySet.h index 7170c12c6..392f8218c 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/CopyOnWriteArraySet.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/CopyOnWriteArraySet.h @@ -20,13 +20,12 @@ #include #include -#include #include #include -#include #include #include #include +#include namespace decaf { diff --git a/activemq-cpp/src/main/decaf/util/concurrent/CountDownLatch.cpp b/activemq-cpp/src/main/decaf/util/concurrent/CountDownLatch.cpp index 19b4dbe3e..333f2a5ef 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/CountDownLatch.cpp +++ b/activemq-cpp/src/main/decaf/util/concurrent/CountDownLatch.cpp @@ -1,174 +1,172 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "CountDownLatch.h" - -#include -#include -#include -#include - -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; -using namespace decaf::util; -using namespace decaf::util::concurrent; -using namespace decaf::util::concurrent::locks; - -//////////////////////////////////////////////////////////////////////////////// -namespace decaf -{ -namespace util -{ - namespace concurrent - { - - class LatchSync : public AbstractQueuedSynchronizer - { - private: - LatchSync(const LatchSync&); - LatchSync& operator=(const LatchSync&); - - public: - LatchSync(int count) - : AbstractQueuedSynchronizer() - { - this->setState(count); - } - - virtual ~LatchSync() - { - } - - int getCount() const - { - return getState(); - } - - protected: - virtual int tryAcquireShared(int acquires DECAF_UNUSED) - { - return getState() == 0 ? 1 : -1; - } - - virtual bool tryReleaseShared(int releases DECAF_UNUSED) - { - for (;;) - { - int current = getState(); - if (current == 0) - { - return false; - } - - int next = current - 1; - if (compareAndSetState(current, next)) - { - return next == 0; - } - } - } - }; - - } // namespace concurrent -} // namespace util -} // namespace decaf - -//////////////////////////////////////////////////////////////////////////////// -CountDownLatch::CountDownLatch(int count) - : sync(NULL) -{ - if (count < 0) - { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Count must be non-negative."); - } - - this->sync = new LatchSync(count); -} - -//////////////////////////////////////////////////////////////////////////////// -CountDownLatch::~CountDownLatch() -{ - try - { - delete sync; - } - DECAF_CATCHALL_NOTHROW() -} - -//////////////////////////////////////////////////////////////////////////////// -void CountDownLatch::await() -{ - try - { - this->sync->acquireSharedInterruptibly(1); - } - DECAF_CATCH_RETHROW(decaf::lang::exceptions::InterruptedException) - DECAF_CATCH_RETHROW(decaf::lang::Exception) - DECAF_CATCHALL_THROW(decaf::lang::Exception) -} - -//////////////////////////////////////////////////////////////////////////////// -bool CountDownLatch::await(long long timeOut) -{ - try - { - return this->sync->tryAcquireSharedNanos( - 1, - TimeUnit::MILLISECONDS.toNanos(timeOut)); - } - DECAF_CATCH_RETHROW(decaf::lang::exceptions::InterruptedException) - DECAF_CATCH_RETHROW(decaf::lang::Exception) - DECAF_CATCHALL_THROW(decaf::lang::Exception) -} - -//////////////////////////////////////////////////////////////////////////////// -bool CountDownLatch::await(long long timeout, const TimeUnit& unit) -{ - try - { - return this->sync->tryAcquireSharedNanos(1, unit.toNanos(timeout)); - } - DECAF_CATCH_RETHROW(decaf::lang::exceptions::InterruptedException) - DECAF_CATCH_RETHROW(decaf::lang::Exception) - DECAF_CATCHALL_THROW(decaf::lang::Exception) -} - -//////////////////////////////////////////////////////////////////////////////// -void CountDownLatch::countDown() -{ - try - { - this->sync->releaseShared(1); - } - DECAF_CATCHALL_NOTHROW() -} - -//////////////////////////////////////////////////////////////////////////////// -int CountDownLatch::getCount() const -{ - return this->sync->getCount(); -} - -//////////////////////////////////////////////////////////////////////////////// -std::string CountDownLatch::toString() const -{ - return std::string("CountDownLatch[count = ") + - Integer::toString(this->sync->getCount()) + "]"; -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "CountDownLatch.h" + +#include +#include +#include +#include +#include +#include + +using namespace decaf; +using namespace decaf::lang; +using namespace decaf::util; +using namespace decaf::util::concurrent; +using namespace decaf::util::concurrent::locks; + +//////////////////////////////////////////////////////////////////////////////// +namespace decaf +{ +namespace util +{ + namespace concurrent + { + + class LatchSync : public AbstractQueuedSynchronizer + { + private: + LatchSync(const LatchSync&); + LatchSync& operator=(const LatchSync&); + + public: + LatchSync(int count) + : AbstractQueuedSynchronizer() + { + this->setState(count); + } + + virtual ~LatchSync() + { + } + + int getCount() const + { + return getState(); + } + + protected: + virtual int tryAcquireShared(int acquires DECAF_UNUSED) + { + return getState() == 0 ? 1 : -1; + } + + virtual bool tryReleaseShared(int releases DECAF_UNUSED) + { + for (;;) + { + int current = getState(); + if (current == 0) + { + return false; + } + + int next = current - 1; + if (compareAndSetState(current, next)) + { + return next == 0; + } + } + } + }; + + } // namespace concurrent +} // namespace util +} // namespace decaf + +//////////////////////////////////////////////////////////////////////////////// +CountDownLatch::CountDownLatch(int count) + : sync(NULL) +{ + if (count < 0) + { + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Count must be non-negative."); + } + + this->sync = new LatchSync(count); +} + +//////////////////////////////////////////////////////////////////////////////// +CountDownLatch::~CountDownLatch() +{ + try + { + delete sync; + } + DECAF_CATCHALL_NOTHROW() +} + +//////////////////////////////////////////////////////////////////////////////// +void CountDownLatch::await() +{ + try + { + this->sync->acquireSharedInterruptibly(1); + } + DECAF_CATCH_RETHROW(decaf::lang::Exception) + DECAF_CATCHALL_THROW(decaf::lang::Exception) +} + +//////////////////////////////////////////////////////////////////////////////// +bool CountDownLatch::await(long long timeOut) +{ + try + { + return this->sync->tryAcquireSharedNanos( + 1, + TimeUnit::MILLISECONDS.toNanos(timeOut)); + } + DECAF_CATCH_RETHROW(decaf::lang::Exception) + DECAF_CATCHALL_THROW(decaf::lang::Exception) +} + +//////////////////////////////////////////////////////////////////////////////// +bool CountDownLatch::await(long long timeout, const TimeUnit& unit) +{ + try + { + return this->sync->tryAcquireSharedNanos(1, unit.toNanos(timeout)); + } + DECAF_CATCH_RETHROW(decaf::lang::Exception) + DECAF_CATCHALL_THROW(decaf::lang::Exception) +} + +//////////////////////////////////////////////////////////////////////////////// +void CountDownLatch::countDown() +{ + try + { + this->sync->releaseShared(1); + } + DECAF_CATCHALL_NOTHROW() +} + +//////////////////////////////////////////////////////////////////////////////// +int CountDownLatch::getCount() const +{ + return this->sync->getCount(); +} + +//////////////////////////////////////////////////////////////////////////////// +std::string CountDownLatch::toString() const +{ + return std::string("CountDownLatch[count = ") + + Integer::toString(this->sync->getCount()) + "]"; +} diff --git a/activemq-cpp/src/main/decaf/util/concurrent/CountDownLatch.h b/activemq-cpp/src/main/decaf/util/concurrent/CountDownLatch.h index 9d498e40b..88b078804 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/CountDownLatch.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/CountDownLatch.h @@ -19,10 +19,10 @@ #define _DECAF_CONCURRENT_COUNTDOWNLATCH_H_ #include -#include #include #include #include +#include namespace decaf { @@ -71,10 +71,10 @@ namespace util * * has its interrupted status set on entry to this method; or * * is interrupted while waiting, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. * - * @throws InterruptedException - if the current thread is + * @throws std::runtime_error - if the current thread is * interrupted while waiting. * @throws Exception - if any other error occurs. */ @@ -105,7 +105,7 @@ namespace util * * has its interrupted status set on entry to this method; or * * is interrupted while waiting, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. * * If the specified waiting time elapses then the value false is @@ -115,7 +115,7 @@ namespace util * @param timeout - Time in milliseconds to wait for the count to * reach zero. * - * @throws InterruptedException - if the current thread is + * @throws std::runtime_error - if the current thread is * interrupted while waiting. * @throws Exception - if any other error occurs. */ @@ -146,7 +146,7 @@ namespace util * * has its interrupted status set on entry to this method; or * * is interrupted while waiting, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. * * If the specified waiting time elapses then the value false is @@ -156,7 +156,7 @@ namespace util * @param timeout - Time to wait for the count to reach zero. * @param unit - The units that the timeout specifies. * - * @throws InterruptedException - if the current thread is + * @throws std::runtime_error - if the current thread is * interrupted while waiting. * @throws Exception - if any other error occurs. */ diff --git a/activemq-cpp/src/main/decaf/util/concurrent/Executor.h b/activemq-cpp/src/main/decaf/util/concurrent/Executor.h index 5b07c6cb9..feabc5508 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/Executor.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/Executor.h @@ -21,7 +21,6 @@ #include #include -#include #include namespace decaf @@ -105,7 +104,7 @@ namespace util * @throws RejectedExecutionException if this task cannot be * accepted for execution. * - * @throws NullPointerException if command is null + * @throws std::logic_error if command is null */ virtual void execute(decaf::lang::Runnable* command) = 0; @@ -124,7 +123,7 @@ namespace util * @throws RejectedExecutionException if this task cannot be * accepted for execution. * - * @throws NullPointerException if command is null + * @throws std::logic_error if command is null */ virtual void execute(decaf::lang::Runnable* command, bool takeOwnership) = 0; diff --git a/activemq-cpp/src/main/decaf/util/concurrent/ExecutorService.h b/activemq-cpp/src/main/decaf/util/concurrent/ExecutorService.h index f790c9ae0..c1f36b460 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/ExecutorService.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/ExecutorService.h @@ -20,13 +20,14 @@ #include +#include #include -#include #include #include #include #include #include +#include namespace decaf { @@ -89,7 +90,7 @@ namespace util * @return true if the executor terminated or false if the timeout * expired. * - * @throws InterruptedException if this call is interrupted while + * @throws std::runtime_error if this call is interrupted while * awaiting termination. */ virtual bool awaitTermination(long long timeout, @@ -156,7 +157,8 @@ namespace util * * @throws RejectedExecutionException if the task cannot be * scheduled for execution - * @throws NullPointerException if the task is null + * @throws activemq::exceptions::NullPointerException if the + * task is null */ template Future* submit(Callable* task, bool takeOwnership = true) @@ -191,8 +193,6 @@ namespace util ex.setMark(__FILE__, __LINE__); throw; } - DECAF_CATCH_RETHROW( - decaf::lang::exceptions::NullPointerException) DECAF_CATCHALL_THROW(decaf::lang::Exception) } @@ -218,7 +218,8 @@ namespace util * * @throws RejectedExecutionException if the task cannot be * scheduled for execution - * @throws NullPointerException if the task is null + * @throws activemq::exceptions::NullPointerException if the + * task is null */ template Future* submit(decaf::lang::Runnable* task, @@ -255,8 +256,6 @@ namespace util ex.setMark(__FILE__, __LINE__); throw; } - DECAF_CATCH_RETHROW( - decaf::lang::exceptions::NullPointerException) DECAF_CATCHALL_THROW(decaf::lang::Exception) } @@ -280,8 +279,8 @@ namespace util * * @throws RejectedExecutionException if the task cannot be * scheduled for execution - * @throws NullPointerException if the Runnable pointer passed is - * NULL. + * @throws activemq::exceptions::NullPointerException if the + * Runnable pointer passed is NULL. */ template Future* submit(decaf::lang::Runnable* task, @@ -317,8 +316,6 @@ namespace util ex.setMark(__FILE__, __LINE__); throw; } - DECAF_CATCH_RETHROW( - decaf::lang::exceptions::NullPointerException) DECAF_CATCHALL_THROW(decaf::lang::Exception) } diff --git a/activemq-cpp/src/main/decaf/util/concurrent/Executors.cpp b/activemq-cpp/src/main/decaf/util/concurrent/Executors.cpp index a6937248f..d83c7b4c8 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/Executors.cpp +++ b/activemq-cpp/src/main/decaf/util/concurrent/Executors.cpp @@ -17,23 +17,24 @@ #include "Executors.h" +#include #include #include #include -#include #include #include #include #include #include #include +#include +#include using namespace decaf; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::atomic; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// namespace @@ -61,7 +62,8 @@ class DefaultThreadFactory : public ThreadFactory { if (DefaultThreadFactory::poolNumber == NULL) { - throw NullPointerException(); + throw activemq::exceptions::NullPointerException( + "Executors thread pool counter was not initialized"); } namePrefix = std::string("pool-") + @@ -196,15 +198,13 @@ ExecutorService* Executors::newFixedThreadPool(int nThreads) return service; } - catch (NullPointerException& ex) + catch (activemq::exceptions::NullPointerException&) { - ex.setMark(__FILE__, __LINE__); - throw ex; + throw; } - catch (IllegalArgumentException& ex) + catch (std::invalid_argument&) { - ex.setMark(__FILE__, __LINE__); - throw ex; + throw; } catch (Exception& ex) { @@ -213,7 +213,7 @@ ExecutorService* Executors::newFixedThreadPool(int nThreads) } catch (...) { - throw Exception(); + throw activemq::exceptions::RuntimeException(); } } @@ -238,15 +238,13 @@ ExecutorService* Executors::newFixedThreadPool(int nThreads, return service; } - catch (NullPointerException& ex) + catch (activemq::exceptions::NullPointerException&) { - ex.setMark(__FILE__, __LINE__); - throw ex; + throw; } - catch (IllegalArgumentException& ex) + catch (std::invalid_argument&) { - ex.setMark(__FILE__, __LINE__); - throw ex; + throw; } catch (Exception& ex) { @@ -255,7 +253,7 @@ ExecutorService* Executors::newFixedThreadPool(int nThreads, } catch (...) { - throw Exception(); + throw activemq::exceptions::RuntimeException(); } } @@ -281,15 +279,13 @@ ExecutorService* Executors::newSingleThreadExecutor() return result; } - catch (NullPointerException& ex) + catch (activemq::exceptions::NullPointerException&) { - ex.setMark(__FILE__, __LINE__); - throw ex; + throw; } - catch (IllegalArgumentException& ex) + catch (std::invalid_argument&) { - ex.setMark(__FILE__, __LINE__); - throw ex; + throw; } catch (Exception& ex) { @@ -298,7 +294,7 @@ ExecutorService* Executors::newSingleThreadExecutor() } catch (...) { - throw Exception(); + throw activemq::exceptions::RuntimeException(); } } @@ -325,15 +321,13 @@ ExecutorService* Executors::newSingleThreadExecutor(ThreadFactory* threadFactory return result; } - catch (NullPointerException& ex) + catch (activemq::exceptions::NullPointerException&) { - ex.setMark(__FILE__, __LINE__); - throw ex; + throw; } - catch (IllegalArgumentException& ex) + catch (std::invalid_argument&) { - ex.setMark(__FILE__, __LINE__); - throw ex; + throw; } catch (Exception& ex) { @@ -342,7 +336,7 @@ ExecutorService* Executors::newSingleThreadExecutor(ThreadFactory* threadFactory } catch (...) { - throw Exception(); + throw activemq::exceptions::RuntimeException(); } } @@ -354,9 +348,10 @@ ExecutorService* Executors::unconfigurableExecutorService( { if (executor == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The wrapped service cannot be NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The wrapped service cannot be NULL"); } NonConfigurableExecutorService* result = @@ -364,15 +359,13 @@ ExecutorService* Executors::unconfigurableExecutorService( return result; } - catch (NullPointerException& ex) + catch (activemq::exceptions::NullPointerException&) { - ex.setMark(__FILE__, __LINE__); - throw ex; + throw; } - catch (IllegalArgumentException& ex) + catch (std::invalid_argument&) { - ex.setMark(__FILE__, __LINE__); - throw ex; + throw; } catch (Exception& ex) { @@ -381,6 +374,6 @@ ExecutorService* Executors::unconfigurableExecutorService( } catch (...) { - throw Exception(); + throw activemq::exceptions::RuntimeException(); } } diff --git a/activemq-cpp/src/main/decaf/util/concurrent/Executors.h b/activemq-cpp/src/main/decaf/util/concurrent/Executors.h index 51ca57f7c..8aea7a030 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/Executors.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/Executors.h @@ -24,7 +24,8 @@ #include #include -#include +#include +#include namespace decaf { @@ -131,7 +132,7 @@ namespace util * @return pointer to a new ExecutorService that is owned by the * caller. * - * @throws IllegalArgumentException if nThreads is less than or + * @throws std::invalid_argument if nThreads is less than or * equal to zero. */ static ExecutorService* newFixedThreadPool(int nThreads); @@ -158,8 +159,8 @@ namespace util * @return pointer to a new ExecutorService that is owned by the * caller. * - * @throws NullPointerException if threadFactory is NULL. - * @throws IllegalArgumentException if nThreads is less than or + * @throws std::logic_error if threadFactory is NULL. + * @throws std::invalid_argument if nThreads is less than or * equal to zero. */ static ExecutorService* newFixedThreadPool( @@ -199,7 +200,7 @@ namespace util * * @return a new Executor pointer that is owned by the caller. * - * @throws NullPointerException if threadFactory is NULL. + * @throws std::logic_error if threadFactory is NULL. */ static ExecutorService* newSingleThreadExecutor( ThreadFactory* threadFactory); @@ -219,7 +220,7 @@ namespace util * @return a new ExecutorService pointer that is owned by the * caller. * - * @throws NullPointerException if ExecutorService is NULL. + * @throws std::logic_error if ExecutorService is NULL. */ static ExecutorService* unconfigurableExecutorService( ExecutorService* executor); @@ -237,7 +238,7 @@ namespace util * * @return a new Callable pointer that is owned by the caller. * - * @throws NullPointerException if the Runnable task is NULL + * @throws std::logic_error if the Runnable task is NULL */ template static Callable* callable(decaf::lang::Runnable* task, @@ -245,7 +246,7 @@ namespace util { if (task == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The Runnable task argument cannot be NULL"); @@ -269,7 +270,7 @@ namespace util * * @return a new Callable pointer that is owned by the caller. * - * @throws NullPointerException if the Runnable task is NULL + * @throws std::logic_error if the Runnable task is NULL */ template static Callable* callable(decaf::lang::Runnable* task, @@ -278,7 +279,7 @@ namespace util { if (task == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The Runnable task argument cannot be NULL"); diff --git a/activemq-cpp/src/main/decaf/util/concurrent/Future.h b/activemq-cpp/src/main/decaf/util/concurrent/Future.h index 470306622..a6b90f2b6 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/Future.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/Future.h @@ -108,7 +108,7 @@ namespace util * * @throws CancellationException if the computation was canceled * @throws ExecutionException if the computation threw an exception - * @throws InterruptedException if the current thread was + * @throws std::runtime_error if the current thread was * interrupted while waiting */ virtual V get() = 0; @@ -126,7 +126,7 @@ namespace util * * @throws CancellationException if the computation was canceled * @throws ExecutionException if the computation threw an exception - * @throws InterruptedException if the current thread was + * @throws std::runtime_error if the current thread was * interrupted while waiting * @throws TimeoutException if the wait timed out before the future * completed. diff --git a/activemq-cpp/src/main/decaf/util/concurrent/FutureTask.h b/activemq-cpp/src/main/decaf/util/concurrent/FutureTask.h index fa94053ef..1560454fd 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/FutureTask.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/FutureTask.h @@ -20,9 +20,10 @@ #include +#include #include #include -#include +#include #include #include @@ -433,14 +434,14 @@ namespace util * Boolean value indicating if the Executor now owns the * pointer to the task. * - * @throws NullPointerException if callable pointer is NULL + * @throws std::logic_error if callable pointer is NULL */ FutureTask(Callable* callable, bool takeOwnership = true) : sync(NULL) { if (callable == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The Callable pointer passed to the constructor was " @@ -465,7 +466,7 @@ namespace util * Boolean value indicating if the Executor now owns the * pointer to the task. * - * @throws NullPointerException if runnable is NULL. + * @throws std::logic_error if runnable is NULL. */ FutureTask(decaf::lang::Runnable* runnable, const T& result, @@ -474,7 +475,7 @@ namespace util { if (runnable == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The Runnable pointer passed to the constructor was " diff --git a/activemq-cpp/src/main/decaf/util/concurrent/LinkedBlockingQueue.h b/activemq-cpp/src/main/decaf/util/concurrent/LinkedBlockingQueue.h index 8ac0a72c3..a1bfbed99 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/LinkedBlockingQueue.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/LinkedBlockingQueue.h @@ -20,17 +20,17 @@ #include +#include #include #include #include -#include -#include #include #include -#include #include #include #include +#include +#include namespace decaf { @@ -197,7 +197,7 @@ namespace util * @param capacity * The initial capacity value to assign to this Queue. * - * @throws IllegalArgumentException if the specified capacity is not + * @throws std::invalid_argument if the specified capacity is not * greater than zero. */ LinkedBlockingQueue(int capacity) @@ -213,10 +213,9 @@ namespace util { if (capacity <= 0) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Capacity value must be greater than zero."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Capacity value must be greater than zero."); } this->tail = this->head; @@ -233,7 +232,7 @@ namespace util * The Collection whose elements are to be copied to this * Queue. * - * @throws IllegalStateException if the number of elements in the + * @throws std::logic_error if the number of elements in the * collection exceeds this Queue's capacity. */ LinkedBlockingQueue(const Collection& collection) @@ -261,7 +260,7 @@ namespace util { if (count == this->capacity) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Number of elements in the Collection exceeds " @@ -274,8 +273,6 @@ namespace util this->count.set(count); } - DECAF_CATCH_RETHROW( - decaf::lang::exceptions::IllegalStateException) DECAF_CATCH_RETHROW(decaf::lang::Exception) DECAF_CATCHALL_THROW(decaf::lang::Exception) } @@ -289,8 +286,9 @@ namespace util * The LinkedBlockingQueue whose elements are to be copied to * this Queue. * - * @throws IllegalStateException if the number of elements in the - * collection exceeds this Queue's capacity. + * @throws activemq::exceptions::IllegalStateException if + * the number of elements in the collection exceeds this Queue's + * capacity. */ LinkedBlockingQueue(const LinkedBlockingQueue& queue) : BlockingQueue(), @@ -317,7 +315,7 @@ namespace util { if (count == this->capacity) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Number of elements in the Collection exceeds " @@ -330,8 +328,6 @@ namespace util this->count.set(count); } - DECAF_CATCH_RETHROW( - decaf::lang::exceptions::IllegalStateException) DECAF_CATCH_RETHROW(decaf::lang::Exception) DECAF_CATCHALL_THROW(decaf::lang::Exception) } @@ -418,7 +414,7 @@ namespace util this->notFull->signal(); } } - catch (decaf::lang::Exception& ex) + catch (...) { this->putLock.unlock(); throw; @@ -449,6 +445,7 @@ namespace util { if (nanos <= 0) { + this->putLock.unlock(); return false; } @@ -463,7 +460,7 @@ namespace util this->notFull->signal(); } } - catch (decaf::lang::Exception& ex) + catch (...) { this->putLock.unlock(); throw; @@ -501,7 +498,7 @@ namespace util } } } - catch (decaf::lang::Exception& ex) + catch (...) { this->putLock.unlock(); throw; @@ -542,7 +539,7 @@ namespace util this->notEmpty->signal(); } } - catch (decaf::lang::Exception& ex) + catch (...) { this->takeLock.unlock(); throw; @@ -575,6 +572,7 @@ namespace util { if (nanos <= 0) { + this->takeLock.unlock(); return false; } @@ -589,7 +587,7 @@ namespace util this->notEmpty->signal(); } } - catch (decaf::lang::Exception& ex) + catch (...) { this->takeLock.unlock(); throw; @@ -632,6 +630,11 @@ namespace util this->takeLock.unlock(); throw; } + catch (std::exception&) + { + this->takeLock.unlock(); + throw; + } this->takeLock.unlock(); @@ -668,6 +671,11 @@ namespace util this->takeLock.unlock(); throw; } + catch (std::exception&) + { + this->takeLock.unlock(); + throw; + } this->takeLock.unlock(); @@ -727,10 +735,9 @@ namespace util { if (&sink == this) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Cannot drain this Collection to itself."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Cannot drain this Collection to itself."); } bool signalNotFull = false; @@ -764,6 +771,14 @@ namespace util delayed = e; shouldThrow = true; } + catch (std::exception& e) + { + delayed = decaf::lang::Exception(__FILE__, + __LINE__, + "%s", + e.what()); + shouldThrow = true; + } if (i > 0) { @@ -777,6 +792,11 @@ namespace util this->takeLock.unlock(); throw; } + catch (std::exception&) + { + this->takeLock.unlock(); + throw; + } this->takeLock.unlock(); @@ -833,9 +853,7 @@ namespace util if (this->current == NULL) { - throw decaf::util::NoSuchElementException( - __FILE__, - __LINE__, + throw activemq::exceptions::NoSuchElementException( "Iterator next called with no matching next " "element."); } @@ -853,7 +871,7 @@ namespace util { if (this->last == NULL) { - throw decaf::lang::exceptions::IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Iterator remove called without having called " @@ -943,9 +961,7 @@ namespace util if (this->current == NULL) { - throw decaf::util::NoSuchElementException( - __FILE__, - __LINE__, + throw activemq::exceptions::NoSuchElementException( "Iterator next called with no matching next " "element."); } @@ -961,7 +977,7 @@ namespace util virtual void remove() { - throw lang::exceptions::UnsupportedOperationException( + throw activemq::exceptions::UnsupportedOperationException( __FILE__, __LINE__, "Cannot write to a const ListIterator."); @@ -1039,6 +1055,11 @@ namespace util this->takeLock.unlock(); throw; } + catch (std::exception&) + { + this->takeLock.unlock(); + throw; + } this->takeLock.unlock(); } diff --git a/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp b/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp index 45bcf2d1d..e22a92406 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp +++ b/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp @@ -22,19 +22,21 @@ #include #include #include -#include +#include +#include #include #include #include #include +#include +#include #include using namespace decaf; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using decaf::internal::util::concurrent::CustomReentrantLock; //////////////////////////////////////////////////////////////////////////////// @@ -211,34 +213,34 @@ void Mutex::wait(long long millisecs, int nanos) { if (millisecs < 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Milliseconds value cannot be negative."); } if (nanos < 0 || nanos > 999999) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Nanoseconds value must be in the range [0..999999]."); } // Check if the current thread has been interrupted before waiting if (Thread::interrupted()) { - throw InterruptedException(__FILE__, - __LINE__, - "Thread interrupted before wait"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Thread interrupted before wait"); } // Verify that we own the lock if (!this->properties->reentrantLock.isHeldByCurrentThread()) { - throw IllegalMonitorStateException(__FILE__, - __LINE__, - "Thread does not own the mutex"); + throw activemq::exceptions::IllegalMonitorStateException( + __FILE__, + __LINE__, + "Thread does not own the mutex"); } // Get current thread handle to manage state @@ -305,7 +307,7 @@ void Mutex::wait(long long millisecs, int nanos) savedRecursionCount); // Restore thread state handle->state.store(savedState, std::memory_order_release); - throw InterruptedException( + throw activemq::exceptions::InterruptedException( __FILE__, __LINE__, "Thread interrupted during wait"); @@ -367,11 +369,7 @@ void Mutex::wait(long long millisecs, int nanos) // condition variable) this->properties->reentrantLock.adoptLock(savedRecursionCount); } - catch (InterruptedException&) - { - // InterruptedException is already handled above, just rethrow - throw; - } + AMQ_CATCHALL_RETHROW_STL_BACKED_EXCEPTIONS() catch (...) { // If something goes wrong, restore the lock state @@ -388,9 +386,10 @@ void Mutex::wait(long long millisecs, int nanos) // Check if thread was interrupted during wait if (Thread::interrupted()) { - throw InterruptedException(__FILE__, - __LINE__, - "Thread interrupted during wait"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Thread interrupted during wait"); } } @@ -399,9 +398,10 @@ void Mutex::notify() { if (!this->properties->reentrantLock.isHeldByCurrentThread()) { - throw IllegalMonitorStateException(__FILE__, - __LINE__, - "Thread does not own the mutex"); + throw activemq::exceptions::IllegalMonitorStateException( + __FILE__, + __LINE__, + "Thread does not own the mutex"); } // Add one pending notification that will be consumed by exactly one waiting // thread @@ -415,9 +415,10 @@ void Mutex::notifyAll() { if (!this->properties->reentrantLock.isHeldByCurrentThread()) { - throw IllegalMonitorStateException(__FILE__, - __LINE__, - "Thread does not own the mutex"); + throw activemq::exceptions::IllegalMonitorStateException( + __FILE__, + __LINE__, + "Thread does not own the mutex"); } // Increment the generation counter to signal all waiting threads. // Each waiting thread records the generation when entering wait() and diff --git a/activemq-cpp/src/main/decaf/util/concurrent/Semaphore.cpp b/activemq-cpp/src/main/decaf/util/concurrent/Semaphore.cpp index 329747f07..091fd2b28 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/Semaphore.cpp +++ b/activemq-cpp/src/main/decaf/util/concurrent/Semaphore.cpp @@ -19,11 +19,13 @@ #include +#include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::locks; @@ -237,9 +239,8 @@ void Semaphore::acquire(int permits) { if (permits < 0) { - throw new IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Value of acquired permits must be greater than zero."); } @@ -251,9 +252,8 @@ void Semaphore::acquireUninterruptibly(int permits DECAF_UNUSED) { if (permits < 0) { - throw new IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Value of acquired permits must be greater than zero."); } @@ -265,9 +265,8 @@ bool Semaphore::tryAcquire(int permits) { if (permits < 0) { - throw new IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Value of acquired permits must be greater than zero."); } @@ -279,9 +278,8 @@ bool Semaphore::tryAcquire(int permits, long long timeout, const TimeUnit& unit) { if (permits < 0) { - throw new IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Value of acquired permits must be greater than zero."); } @@ -293,9 +291,8 @@ void Semaphore::release(int permits) { if (permits < 0) { - throw new IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Value of acquired permits must be greater than zero."); } diff --git a/activemq-cpp/src/main/decaf/util/concurrent/Semaphore.h b/activemq-cpp/src/main/decaf/util/concurrent/Semaphore.h index 87e7c9a05..546ca4e48 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/Semaphore.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/Semaphore.h @@ -20,9 +20,8 @@ #include -#include -#include -#include +#include +#include #include #include @@ -65,7 +64,7 @@ namespace util * items.resize( MAX_AVAILABLE ); * } * - * std::string getItem() throws InterruptedException { + * std::string getItem() throws std::runtime_error { * available.acquire(); * return getNextAvailableItem(); * } @@ -210,12 +209,12 @@ namespace util * * has its interrupted status set on entry to this method; or * * is interrupted while waiting for a permit, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. * - * @throw InterruptedException - if the current thread is + * @throw std::runtime_error - if the current thread is * interrupted. - * @throw RuntimeException if an unexpected error occurs while + * @throw Exception if an unexpected error occurs while * acquiring the Semaphore. */ void acquire(); @@ -239,7 +238,7 @@ namespace util * thread does return from this method its interrupt status will be * set. * - * @throw RuntimeException if an unexpected error occurs while + * @throw Exception if an unexpected error occurs while * acquiring the Semaphore. */ void acquireUninterruptibly(); @@ -266,7 +265,7 @@ namespace util * * @return true if a permit was acquired and false otherwise * - * @throw RuntimeException if an unexpected error occurs while + * @throw Exception if an unexpected error occurs while * acquiring the Semaphore. */ bool tryAcquire(); @@ -297,7 +296,7 @@ namespace util * * has its interrupted status set on entry to this method; or * * is interrupted while waiting to acquire a permit, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. * * If the specified waiting time elapses then the value false is @@ -310,8 +309,8 @@ namespace util * @return true if a permit was acquired and false if the waiting * time elapsed before a permit was acquired * - * @throw InterruptedException if the current thread is interrupted. - * @throw RuntimeException if an unexpected error occurs while + * @throw std::runtime_error if the current thread is interrupted. + * @throw Exception if an unexpected error occurs while * acquiring the Semaphore. */ bool tryAcquire(long long timeout, const TimeUnit& unit); @@ -329,7 +328,7 @@ namespace util * a semaphore is established by programming convention in the * application. * - * @throw RuntimeException if an unexpected error occurs while + * @throw Exception if an unexpected error occurs while * releasing the Semaphore. */ void release(); @@ -356,7 +355,7 @@ namespace util * * has its interrupted status set on entry to this method; or * * is interrupted while waiting for a permit, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. Any permits that were to be * assigned to this thread are instead assigned to other threads * trying to acquire permits, as if permits had been made available @@ -364,10 +363,10 @@ namespace util * * @param permits the number of permits to acquire. * - * @throw InterruptedException if the current thread is interrupted. - * @throw IllegalArgumentException if the permits argument is + * @throw std::runtime_error if the current thread is interrupted. + * @throws std::invalid_argument if the permits argument is * negative. - * @throw RuntimeException if an unexpected error occurs while + * @throw Exception if an unexpected error occurs while * acquiring the Semaphore. */ void acquire(int permits); @@ -393,9 +392,9 @@ namespace util * * @param permits the number of permits to acquire. * - * @throw IllegalArgumentException if the permits argument is + * @throws std::invalid_argument if the permits argument is * negative. - * @throw RuntimeException if an unexpected error occurs while + * @throw Exception if an unexpected error occurs while * acquiring the Semaphore. */ void acquireUninterruptibly(int permits); @@ -425,9 +424,9 @@ namespace util * * @return true if the permits were acquired and false otherwise. * - * @throw IllegalArgumentException if the permits argument is + * @throws std::invalid_argument if the permits argument is * negative. - * @throw RuntimeException if an unexpected error occurs while + * @throw Exception if an unexpected error occurs while * acquiring the Semaphore. */ bool tryAcquire(int permits); @@ -458,7 +457,7 @@ namespace util * * has its interrupted status set on entry to this method; or * * is interrupted while waiting to acquire the permits, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. Any permits that were to be * assigned to this thread, are instead assigned to other threads * trying to acquire permits, as if the permits had been made @@ -479,9 +478,9 @@ namespace util * @return true if all permits were acquired and false if the * waiting time elapsed before all permits were acquired * - * @throw IllegalArgumentException if the permits argument is + * @throws std::invalid_argument if the permits argument is * negative. - * @throw RuntimeException if an unexpected error occurs while + * @throw Exception if an unexpected error occurs while * acquiring the Semaphore. */ bool tryAcquire(int permits, @@ -505,9 +504,9 @@ namespace util * * @param permits the number of permits to release * - * @throw IllegalArgumentException if the permits argument is + * @throws std::invalid_argument if the permits argument is * negative. - * @throw RuntimeException if an unexpected error occurs while + * @throw Exception if an unexpected error occurs while * releasing the Semaphore. */ void release(int permits); @@ -527,7 +526,7 @@ namespace util * * @return the number of permits acquired * - * @throw RuntimeException if an unexpected error occurs while + * @throw Exception if an unexpected error occurs while * draining the Semaphore. */ int drainPermits(); @@ -575,7 +574,7 @@ namespace util * The number of permits to remove from the current available * set. * - * @throws IllegalArgumentException if the param passed in negative. + * @throws std::invalid_argument if the param passed in negative. */ void reducePermits(int reduceBy); diff --git a/activemq-cpp/src/main/decaf/util/concurrent/Synchronizable.h b/activemq-cpp/src/main/decaf/util/concurrent/Synchronizable.h index e9f6a997b..5143fc3b0 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/Synchronizable.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/Synchronizable.h @@ -18,11 +18,9 @@ #ifndef _DECAF_UTIL_CONCURRENT_SYNCHRONIZABLE_H_ #define _DECAF_UTIL_CONCURRENT_SYNCHRONIZABLE_H_ -#include -#include -#include -#include +#include #include +#include namespace decaf { @@ -45,7 +43,7 @@ namespace util /** * Locks the object. * - * @throws RuntimeException if an error occurs while locking the + * @throws Exception if an error occurs while locking the * object. */ virtual void lock() = 0; @@ -57,7 +55,7 @@ namespace util * @return true if the lock was acquired, false if it is already * held by another thread. * - * @throws RuntimeException if an error occurs while locking the + * @throws Exception if an error occurs while locking the * object. */ virtual bool tryLock() = 0; @@ -65,7 +63,7 @@ namespace util /** * Unlocks the object. * - * @throws RuntimeException if an error occurs while unlocking the + * @throws Exception if an error occurs while unlocking the * object. */ virtual void unlock() = 0; @@ -75,11 +73,11 @@ namespace util * by a call to Notify. Must have this object locked before * calling. * - * @throws RuntimeException if an error occurs while waiting on the + * @throws Exception if an error occurs while waiting on the * object. - * @throws InterruptedException if the wait is interrupted before it + * @throws std::runtime_error if the wait is interrupted before it * completes. - * @throws IllegalMonitorStateException - if the current thread is + * @throws std::logic_error - if the current thread is * not the owner of the the Synchronizable Object. */ virtual void wait() = 0; @@ -93,11 +91,11 @@ namespace util * @param millisecs * the time in milliseconds to wait, or WAIT_INIFINITE * - * @throws RuntimeException if an error occurs while waiting on the + * @throws Exception if an error occurs while waiting on the * object. - * @throws InterruptedException if the wait is interrupted before it + * @throws std::runtime_error if the wait is interrupted before it * completes. - * @throws IllegalMonitorStateException - if the current thread is + * @throws std::logic_error - if the current thread is * not the owner of the the Synchronizable Object. */ virtual void wait(long long millisecs) = 0; @@ -120,13 +118,13 @@ namespace util * @param nanos * additional time in nanoseconds with a range of 0-999999 * - * @throws IllegalArgumentException if an error occurs or the nanos + * @throws std::invalid_argument if an error occurs or the nanos * argument is not in the range of [0-999999] - * @throws RuntimeException if an error occurs while waiting on the + * @throws Exception if an error occurs while waiting on the * object. - * @throws InterruptedException if the wait is interrupted before it + * @throws std::runtime_error if the wait is interrupted before it * completes. - * @throws IllegalMonitorStateException - if the current thread is + * @throws std::logic_error - if the current thread is * not the owner of the the Synchronizable Object. */ virtual void wait(long long millisecs, int nanos) = 0; @@ -136,9 +134,9 @@ namespace util * up and continue. Must have this object locked before * calling. * - * @throws IllegalMonitorStateException - if the current thread is + * @throws std::logic_error - if the current thread is * not the owner of the the Synchronizable Object. - * @throws RuntimeException if an error occurs while notifying one + * @throws Exception if an error occurs while notifying one * of the waiting threads. */ virtual void notify() = 0; @@ -148,9 +146,9 @@ namespace util * up and continue. Must have this object locked before * calling. * - * @throws IllegalMonitorStateException - if the current thread is + * @throws std::logic_error - if the current thread is * not the owner of the the Synchronizable Object. - * @throws RuntimeException if an error occurs while notifying the + * @throws Exception if an error occurs while notifying the * waiting threads. */ virtual void notifyAll() = 0; diff --git a/activemq-cpp/src/main/decaf/util/concurrent/SynchronousQueue.h b/activemq-cpp/src/main/decaf/util/concurrent/SynchronousQueue.h index 720c1f6ad..d772d4cc7 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/SynchronousQueue.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/SynchronousQueue.h @@ -22,6 +22,9 @@ #include +#include +#include +#include #include namespace decaf @@ -73,9 +76,7 @@ namespace util public: virtual E next() { - throw NoSuchElementException( - __FILE__, - __LINE__, + throw activemq::exceptions::ConcurrentModificationException( "Cannot traverse a Synchronous Queue."); } @@ -86,10 +87,11 @@ namespace util virtual void remove() { - throw lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, - "No Elements to remove from a Synchronous Queue."); + throw activemq::exceptions::TypeMismatchException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + + "No Elements to remove from a " + "Synchronous Queue."); } }; @@ -113,19 +115,27 @@ namespace util * * @param value the element to add to the Queue. * - * @throws InterruptedException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} + * @throws std::runtime_error {@inheritDoc} + * @throws std::logic_error {@inheritDoc} + * @throws std::invalid_argument {@inheritDoc} */ virtual void put(const E& value DECAF_UNUSED) { - // if (o == null) throw new NullPointerException(); + // if (o == null) throw std::logic_error(/*null elem*/); // if (transferer.transfer(o, false, 0) == null) { // Thread.interrupted(); - // throw new InterruptedException(); + // throw new std::runtime_error(); // } } + virtual bool offer(const E& value DECAF_UNUSED) + { + // if (e == null) throw std::logic_error(/*null elem*/); + // return transferer.transfer(e, true, 0) != null; + + return false; + } + /** * Inserts the specified element into this queue, waiting if * necessary up to the specified wait time for another thread to @@ -134,43 +144,21 @@ namespace util * @return true if successful, or false if the * specified waiting time elapses before a consumer appears. * - * @throws InterruptedException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} + * @throws std::runtime_error {@inheritDoc} + * @throws std::logic_error {@inheritDoc} + * @throws std::invalid_argument {@inheritDoc} */ virtual bool offer(const E& e DECAF_UNUSED, long long timeout DECAF_UNUSED, const TimeUnit& unit DECAF_UNUSED) { - // if (o == null) throw new NullPointerException(); + // if (o == null) throw std::logic_error(/*null elem*/); // if (transferer.transfer(o, true, unit.toNanos(timeout)) != // null) // return true; // if (!Thread.interrupted()) // return false; - // throw new InterruptedException(); - - throw false; - } - - /** - * Inserts the specified element into this queue, if another thread - * is waiting to receive it. - * - * @param value the element to add to the Queue - * - * @return true if the element was added to this queue, - * else false - * - * @throws NullPointerException if the Queue implementation does not - * allow Null values to be inserted into the Queue. - * @throws IllegalArgumentException if some property of the - * specified element prevents it from being added to this queue - */ - virtual bool offer(const E& value DECAF_UNUSED) - { - // if (e == null) throw new NullPointerException(); - // return transferer.transfer(e, true, 0) != null; + // throw new std::runtime_error(); return false; } @@ -180,7 +168,7 @@ namespace util * necessary for another thread to insert it. * * @return the head of this queue - * @throws InterruptedException {@inheritDoc} + * @throws std::runtime_error {@inheritDoc} */ virtual E take() { @@ -188,7 +176,7 @@ namespace util // if (e != null) // return (E)e; // Thread.interrupted(); - // throw new InterruptedException(); + // throw new std::runtime_error(); return E(); } @@ -215,7 +203,7 @@ namespace util // unit.toNanos(timeout)); if (e != null || // !Thread.interrupted()) // return (E)e; - // throw new InterruptedException(); + // throw new std::runtime_error(); return false; } @@ -313,10 +301,9 @@ namespace util { if ((void*)&c == this) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Cannot drain a Collection to Itself."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Cannot drain a Collection to Itself."); } int count = 0; @@ -335,10 +322,9 @@ namespace util { if ((void*)&c == this) { - throw decaf::lang::exceptions::IllegalArgumentException( - __FILE__, - __LINE__, - "Cannot drain a Collection to Itself."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Cannot drain a Collection to Itself."); } int count = 0; diff --git a/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp b/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp index 1fb247072..1e3283c0e 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp +++ b/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp @@ -17,11 +17,9 @@ #include "ThreadPoolExecutor.h" +#include #include #include -#include -#include -#include #include #include #include @@ -36,14 +34,15 @@ #include #include #include +#include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::atomic; @@ -178,9 +177,9 @@ namespace util { if (kernel == NULL) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + "ThreadPoolExecutor Worker requires non-NULL " "pointer to parent ExecutorKernel"); } @@ -417,17 +416,18 @@ namespace util if (corePoolSize < 0 || maxPoolSize <= 0 || maxPoolSize < corePoolSize || keepAliveTime < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Argument out of range."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Argument out of range."); } if (workQueue == NULL || threadFactory == NULL || handler == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Required parameter was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Required parameter was NULL"); } this->cleanupTimer.scheduleAtFixedRate( @@ -463,7 +463,23 @@ namespace util } this->shutdown(); - this->awaitTermination(); + if (!this->awaitTermination(30, TimeUnit::SECONDS)) + { + ArrayList draining; + this->shutdownNow(draining); + try + { + Pointer> drainIter( + draining.iterator()); + while (drainIter->hasNext()) + { + Runnable* leftover = drainIter->next(); + delete leftover; + } + } + DECAF_CATCHALL_NOTHROW() + this->awaitTermination(30, TimeUnit::SECONDS); + } // We need to wait for the worker cleanup timer to shutdown, // otherwise it could segfault if it's still running when @@ -481,14 +497,10 @@ namespace util delete worker; } - Pointer> tasks( - this->workQueue->iterator()); - while (tasks->hasNext()) - { - delete tasks->next(); - } - - this->workQueue->clear(); + // Work queue locks can be left in an inconsistent state + // when shutdown races with interruption paths. Avoid taking + // a full queue iteration lock here to prevent destructor + // deadlocks. } DECAF_CATCH_NOTHROW(Exception) DECAF_CATCHALL_NOTHROW() @@ -823,12 +835,12 @@ namespace util * * 4. Assuming beforeExecute completes normally, we run the task, * gathering any of its thrown exceptions to send to - * afterExecute. We separately handle RuntimeException, Error - * (both of which the specs guarantee that we trap) and arbitrary - * Throwables. Because we cannot rethrow Throwables within - * Runnable.run, we wrap them within Errors on the way out (to the - * thread's UncaughtExceptionHandler). Any thrown exception also - * conservatively causes thread to die. + * afterExecute. We separately handle Decaf Exception, ISO C++ + * std::exception (wrapped into Decaf Exception), and arbitrary + * unknown exceptions (wrapped into Decaf Exception). Runnable.run + * cannot propagate unknown exceptions type-safely, so they become + * Decaf Exceptions before exiting this worker. Any thrown + * exception also conservatively causes thread to die. * * 5. After task.run completes, we call afterExecute, which may * also throw an exception, which will also cause thread to @@ -860,11 +872,6 @@ namespace util { task->run(); } - catch (RuntimeException& re) - { - this->parent->afterExecute(task, &re); - throw; - } catch (Exception& e) { this->parent->afterExecute(task, &e); @@ -921,9 +928,10 @@ namespace util { if (task == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Runnable task cannot be NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Runnable task cannot be NULL"); } Runnable* target = task; @@ -996,7 +1004,7 @@ namespace util interruptIdleWorkers(); this->parent->onShutdown(); } - catch (Exception& ex) + catch (...) { mainLock.unlock(); throw; @@ -1014,7 +1022,7 @@ namespace util interruptWorkers(); drainQueue(unexecutedTasks); } - catch (Exception& ex) + catch (...) { mainLock.unlock(); throw; @@ -1055,13 +1063,11 @@ namespace util this->termination->await(); } } - catch (Exception& ex) + catch (...) { mainLock.unlock(); throw; } - mainLock.unlock(); - return false; } bool awaitTermination(long long timeout, const TimeUnit& unit) @@ -1087,13 +1093,11 @@ namespace util nanos = this->termination->awaitNanos(nanos); } } - catch (Exception& ex) + catch (...) { mainLock.unlock(); throw; } - mainLock.unlock(); - return false; } void setCorePoolSize(int corePoolSize) @@ -1127,7 +1131,10 @@ namespace util { if (maximumPoolSize <= 0 || maximumPoolSize < corePoolSize) { - throw IllegalArgumentException(); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": maximumPoolSize must be " + "positive and >= corePoolSize"); } this->maxPoolSize = maximumPoolSize; @@ -1158,9 +1165,9 @@ namespace util { if (value && keepAliveTime <= 0) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Core threads must have nonzero keep alive times"); } @@ -1178,14 +1185,16 @@ namespace util { if (time < 0) { - throw IllegalArgumentException(); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": keep alive time cannot be negative"); } if (time == 0 && this->coreThreadsCanTimeout) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": " + "Core threads must have nonzero keep alive times"); } @@ -1216,7 +1225,7 @@ namespace util } } } - catch (ConcurrentModificationException& ex) + catch (activemq::exceptions::ConcurrentModificationException&) { // Take slow path if we encounter interference during // traversal. Make copy for traversal and call remove for @@ -1234,6 +1243,20 @@ namespace util } } } + catch (activemq::exceptions::NoSuchElementException&) + { + std::vector array = q->toArray(); + std::vector::const_iterator iter = array.begin(); + for (; iter != array.end(); ++iter) + { + Runnable* r = *iter; + FutureType* future = dynamic_cast(r); + if (r != NULL && future->isCancelled()) + { + q->remove(r); + } + } + } tryTerminate(); // In case SHUTDOWN and now empty } @@ -1381,7 +1404,8 @@ namespace util success: Pointer w(new Worker(this, firstTask)); - Pointer t = w->thread; + Worker* worker = w.get(); + Pointer t = w->thread; mainLock.lock(); try @@ -1402,7 +1426,7 @@ namespace util return false; } - workers.add(w.release()); + workers.add(worker); int s = workers.size(); if (s > largestPoolSize) @@ -1416,9 +1440,20 @@ namespace util throw; } - t->start(); - - mainLock.unlock(); + try + { + t->start(); + w.release(); // ownership transferred to workers list + mainLock.unlock(); + } + catch (...) + { + workers.remove(worker); + decrementWorkerCount(); + mainLock.unlock(); + tryTerminate(); + throw; + } // It is possible (but unlikely) for a thread to have been added // to workers, but not yet started, during transition to STOP, @@ -1553,7 +1588,7 @@ namespace util { workQueue->poll(r, keepAliveTime, - TimeUnit::NANOSECONDS); + TimeUnit::MILLISECONDS); } else { @@ -1567,8 +1602,12 @@ namespace util timedOut = true; } - catch (InterruptedException& retry) + catch (activemq::exceptions::InterruptedException& retry) { + // Keep Java semantics: interruption during queue wait + // is a transient wakeup signal here. Ensure interrupt + // flag does not remain latched across retries. + Thread::interrupted(); timedOut = false; } } @@ -1635,7 +1674,7 @@ ThreadPoolExecutor::ThreadPoolExecutor( { if (workQueue == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The BlockingQueue pointer cannot be NULL."); @@ -1657,8 +1696,6 @@ ThreadPoolExecutor::ThreadPoolExecutor( handler.release(); threadFactory.release(); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_RETHROW(Exception) DECAF_CATCHALL_THROW(Exception) } @@ -1678,7 +1715,7 @@ ThreadPoolExecutor::ThreadPoolExecutor( { if (workQueue == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The BlockingQueue pointer cannot be NULL."); @@ -1686,7 +1723,7 @@ ThreadPoolExecutor::ThreadPoolExecutor( if (handler == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The RejectedExecutionHandler pointer cannot be NULL."); @@ -1705,8 +1742,6 @@ ThreadPoolExecutor::ThreadPoolExecutor( threadFactory.release(); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_RETHROW(Exception) DECAF_CATCHALL_THROW(Exception) } @@ -1726,7 +1761,7 @@ ThreadPoolExecutor::ThreadPoolExecutor( { if (workQueue == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The BlockingQueue pointer cannot be NULL."); @@ -1734,7 +1769,7 @@ ThreadPoolExecutor::ThreadPoolExecutor( if (threadFactory == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The ThreadFactory pointer cannot be NULL."); @@ -1753,8 +1788,6 @@ ThreadPoolExecutor::ThreadPoolExecutor( handler.release(); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_RETHROW(Exception) DECAF_CATCHALL_THROW(Exception) } @@ -1775,7 +1808,7 @@ ThreadPoolExecutor::ThreadPoolExecutor( { if (workQueue == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The BlockingQueue pointer cannot be NULL."); @@ -1783,7 +1816,7 @@ ThreadPoolExecutor::ThreadPoolExecutor( if (handler == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The RejectedExecutionHandler pointer cannot be NULL."); @@ -1791,7 +1824,7 @@ ThreadPoolExecutor::ThreadPoolExecutor( if (threadFactory == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The ThreadFactory pointer cannot be NULL."); @@ -1805,8 +1838,6 @@ ThreadPoolExecutor::ThreadPoolExecutor( threadFactory, handler); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IllegalArgumentException) DECAF_CATCH_RETHROW(Exception) DECAF_CATCHALL_THROW(Exception) } @@ -1829,16 +1860,16 @@ void ThreadPoolExecutor::execute(Runnable* task) { if (task == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "ThreadPoolExecutor::execute - Supplied " - "Runnable pointer was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "ThreadPoolExecutor::execute - Supplied Runnable pointer was " + "NULL."); } this->kernel->execute(task, true); } DECAF_CATCH_RETHROW(RejectedExecutionException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_RETHROW(Exception) DECAF_CATCHALL_THROW(Exception) } @@ -1850,16 +1881,16 @@ void ThreadPoolExecutor::execute(Runnable* task, bool takeOwnership) { if (task == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "ThreadPoolExecutor::execute - Supplied " - "Runnable pointer was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "ThreadPoolExecutor::execute - Supplied Runnable pointer was " + "NULL."); } this->kernel->execute(task, takeOwnership); } DECAF_CATCH_RETHROW(RejectedExecutionException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCH_RETHROW(Exception) DECAF_CATCHALL_THROW(Exception) } @@ -1918,9 +1949,9 @@ void ThreadPoolExecutor::setCorePoolSize(int poolSize) { if (poolSize < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Pool size given was negative."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Pool size given was negative."); } this->kernel->setCorePoolSize(poolSize); @@ -1937,9 +1968,9 @@ void ThreadPoolExecutor::setMaximumPoolSize(int maxSize) { if (maxSize < 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Maximum Pool size given was negative."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Maximum Pool size given was negative."); } this->kernel->setMaximumPoolSize(maxSize); @@ -1974,9 +2005,10 @@ void ThreadPoolExecutor::setThreadFactory(ThreadFactory* factory) { if (factory == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Cannot assign a NULL ThreadFactory."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Cannot assign a NULL ThreadFactory."); } if (factory != this->kernel->factory) @@ -2004,7 +2036,7 @@ void ThreadPoolExecutor::setRejectedExecutionHandler( { if (handler == NULL) { - throw NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Cannot assign a NULL RejectedExecutionHandler."); @@ -2098,7 +2130,7 @@ void ThreadPoolExecutor::beforeExecute(Thread* thread DECAF_UNUSED, //////////////////////////////////////////////////////////////////////////////// void ThreadPoolExecutor::afterExecute(Runnable* task DECAF_UNUSED, - decaf::lang::Throwable* error DECAF_UNUSED) + decaf::lang::Exception* error DECAF_UNUSED) { } diff --git a/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.h b/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.h index 881bbe676..937307368 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.h @@ -17,8 +17,8 @@ #ifndef _DECAF_UTIL_CONCURRENT_THREADPOOLEXECUTOR_H_ #define _DECAF_UTIL_CONCURRENT_THREADPOOLEXECUTOR_H_ +#include #include -#include #include #include #include @@ -29,6 +29,7 @@ #include #include +#include #include namespace decaf @@ -97,7 +98,7 @@ namespace util * keepAliveTime are negative or the or if maximumPoolSize is less * than or equal to zero, or if corePoolSize is greater than * maximumPoolSize. - * @throws NullPointerException if the workQueue pointer is NULL. + * @throws std::logic_error if the workQueue pointer is NULL. */ ThreadPoolExecutor(int corePoolSize, int maxPoolSize, @@ -139,7 +140,7 @@ namespace util * keepAliveTime are negative or the or if maximumPoolSize is less * than or equal to zero, or if corePoolSize is greater than * maximumPoolSize. - * @throws NullPointerException if the workQueue pointer is NULL. + * @throws std::logic_error if the workQueue pointer is NULL. */ ThreadPoolExecutor(int corePoolSize, int maxPoolSize, @@ -181,7 +182,7 @@ namespace util * keepAliveTime are negative or the or if maximumPoolSize is less * than or equal to zero, or if corePoolSize is greater than * maximumPoolSize. - * @throws NullPointerException if the workQueue pointer is NULL. + * @throws std::logic_error if the workQueue pointer is NULL. */ ThreadPoolExecutor(int corePoolSize, int maxPoolSize, @@ -228,7 +229,7 @@ namespace util * keepAliveTime are negative or the or if maximumPoolSize is less * than or equal to zero, or if corePoolSize is greater than * maximumPoolSize. - * @throws NullPointerException if the workQueue pointer is NULL. + * @throws std::logic_error if the workQueue pointer is NULL. */ ThreadPoolExecutor(int corePoolSize, int maxPoolSize, @@ -284,7 +285,7 @@ namespace util * @param poolSize * The new core pool size for this executor. * - * @throws IllegalArgumentException if the pool size value is less + * @throws std::invalid_argument if the pool size value is less * than zero. */ virtual void setCorePoolSize(int poolSize); @@ -307,7 +308,7 @@ namespace util * @param maxSize * The new maximum allowed worker pool size. * - * @throws IllegalArgumentException if maxSize is negative or less + * @throws std::invalid_argument if maxSize is negative or less * than core pool size. */ virtual void setMaximumPoolSize(int maxSize); @@ -384,7 +385,7 @@ namespace util * Boolean value indicating if core threads are allowed to time * out when idle. * - * @throws IllegalArgumentException if the keep alive time is set to + * @throws std::invalid_argument if the keep alive time is set to * zero. */ virtual void allowCoreThreadTimeout(bool value); @@ -425,7 +426,7 @@ namespace util * @param unit * The units that the timeout is given in. * - * @throws IllegalArgumentException if allowCoreThreadsTimeout is + * @throws std::invalid_argument if allowCoreThreadsTimeout is * enabled and the the timeout value given is zero, or the timeout * given is negative. */ @@ -444,7 +445,7 @@ namespace util * A ThreadFactory instance used by this Executor to create new * Threads. * - * @throws NullPointerException if the given factory pointer is + * @throws std::logic_error if the given factory pointer is * NULL. */ virtual void setThreadFactory(ThreadFactory* factory); @@ -476,7 +477,7 @@ namespace util * @param handler * The new RejectedExecutionHandler instance to use. * - * @throws NullPointerException if the handler is NULL. + * @throws std::logic_error if the handler is NULL. */ virtual void setRejectedExecutionHandler( RejectedExecutionHandler* handler); @@ -546,7 +547,7 @@ namespace util /** * Called upon completion of execution of a given task. This method * is called from the Thread that executed the given Runnable. If - * the Throwable pointer is not NULL then its value is the Exception + * error is not NULL then it points to the decaf::lang::Exception * that caused the task to terminate. * * The base class implementation does nothing, a derived class @@ -560,7 +561,7 @@ namespace util * The exception that was thrown from the given Runnable. */ virtual void afterExecute(decaf::lang::Runnable* task, - decaf::lang::Throwable* error); + decaf::lang::Exception* error); /** * Method invoked when the Executor has terminated, by default this @@ -649,6 +650,11 @@ namespace util delete task; throw ex; } + catch (std::exception&) + { + delete task; + throw; + } } }; @@ -721,6 +727,11 @@ namespace util delete task; throw ex; } + catch (std::exception&) + { + delete task; + throw; + } } }; }; diff --git a/activemq-cpp/src/main/decaf/util/concurrent/TimeUnit.cpp b/activemq-cpp/src/main/decaf/util/concurrent/TimeUnit.cpp index 493e2dadc..3f3a68914 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/TimeUnit.cpp +++ b/activemq-cpp/src/main/decaf/util/concurrent/TimeUnit.cpp @@ -17,12 +17,15 @@ #include "TimeUnit.h" +#include +#include +#include + #include #include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -125,9 +128,10 @@ void TimeUnit::timedWait(Synchronizable* obj, long long timeout) const { if (obj == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Synchronizable object pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Synchronizable object pointer was null."); } if (timeout > 0) @@ -143,9 +147,10 @@ void TimeUnit::timedJoin(Thread* thread, long long timeout) { if (thread == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Thread object pointer was null."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Thread object pointer was null."); } if (timeout > 0) @@ -214,9 +219,8 @@ const TimeUnit& TimeUnit::valueOf(const std::string& name) } } - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Passed TimeUnit name; %s, Does not match any instances of TimeUnit", - name.c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": Passed TimeUnit name; " + name + + ", Does not match any instances of TimeUnit"); } diff --git a/activemq-cpp/src/main/decaf/util/concurrent/TimeUnit.h b/activemq-cpp/src/main/decaf/util/concurrent/TimeUnit.h index 809c3239d..0882a6faa 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/TimeUnit.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/TimeUnit.h @@ -19,11 +19,9 @@ #define _DECAF_UTIL_CONCURRENT_TIMEUNIT_H_ #include -#include -#include -#include #include #include +#include #include namespace decaf @@ -229,8 +227,8 @@ namespace util * @param obj the object to wait on * @param timeout the maximum time to wait. * - * @throws InterruptedException if interrupted while waiting. - * @throws NullPointerException if the Synchronizable object is + * @throws std::runtime_error if interrupted while waiting. + * @throws std::logic_error if the Synchronizable object is * null. * * @see Synchronizable#wait( long long, long long ) @@ -245,8 +243,8 @@ namespace util * @param thread the thread to wait for * @param timeout the maximum time to wait * - * @throws InterruptedException if interrupted while waiting. - * @throws NullPointerException if the thread object is null. + * @throws std::runtime_error if interrupted while waiting. + * @throws std::logic_error if the thread object is null. * * @see Thread#join( long long, long long ) */ @@ -279,7 +277,7 @@ namespace util * @return * A constant reference to the TimeUnit Constant with the * given name. - * @throws IllegalArgumentException + * @throws std::invalid_argument * if this enum type has no constant with the specified * name */ diff --git a/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.cpp b/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.cpp index 7053ebfd5..43630ab1d 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.cpp +++ b/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.cpp @@ -17,11 +17,11 @@ #include "AbstractQueuedSynchronizer.h" +#include +#include #include #include -#include -#include -#include +#include #include #include @@ -30,10 +30,10 @@ #include #include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::atomic; @@ -254,7 +254,11 @@ class Node Node* p = prev; if (p == NULL) { - throw NullPointerException(); + throw activemq::exceptions::NullPointerException(__FILE__, + __LINE__, + "Predecessor " + "link was " + "NULL"); } else { @@ -874,17 +878,20 @@ namespace util if (shouldParkAfterFailedAcquire(p, node) && parkAndCheckInterrupt()) { - throw InterruptedException( + throw activemq::exceptions::InterruptedException( __FILE__, __LINE__, "Interrupted while waiting for lock."); } } } + AMQ_CANCEL_AND_RETHROW_RUNTIME_HIERARCHY( + cancelAcquire(node)) catch (Exception& ex) { cancelAcquire(node); - throw InterruptedException(ex); + throw activemq::exceptions::InterruptedException( + ex.what()); } } @@ -930,13 +937,15 @@ namespace util if (Thread::interrupted()) { - throw InterruptedException( + throw activemq::exceptions::InterruptedException( __FILE__, __LINE__, "Interrupted while waiting for lock."); } } } + AMQ_CANCEL_AND_RETHROW_RUNTIME_HIERARCHY( + cancelAcquire(node)) catch (Exception& ex) { cancelAcquire(node); @@ -985,6 +994,8 @@ namespace util } } } + AMQ_CANCEL_AND_RETHROW_RUNTIME_HIERARCHY( + cancelAcquire(node)) catch (Exception& ex) { cancelAcquire(node); @@ -1022,13 +1033,15 @@ namespace util if (shouldParkAfterFailedAcquire(p, node) && parkAndCheckInterrupt()) { - throw InterruptedException( + throw activemq::exceptions::InterruptedException( __FILE__, __LINE__, "Interrupted while waiting for lock."); } } } + AMQ_CANCEL_AND_RETHROW_RUNTIME_HIERARCHY( + cancelAcquire(node)) catch (Exception& ex) { cancelAcquire(node); @@ -1084,7 +1097,7 @@ namespace util if (Thread::interrupted()) { - throw InterruptedException( + throw activemq::exceptions::InterruptedException( __FILE__, __LINE__, "Interrupted while waiting for lock."); @@ -1232,12 +1245,7 @@ namespace util * already then its not added as the signal will have already * done so, we must wait though until it appears on the sync * queue otherwise the attempt to re-acquire the lock could - * throw a NullPointerException. - * - * @param node - * The node that is to be transferred onto the sync queue. - * - * @return true if canceled before the node was signaled + * throw NullPointerException. */ bool transferAfterCancelledWait(Node* node) { @@ -1283,10 +1291,11 @@ namespace util } else { - throw IllegalMonitorStateException(); + throw activemq::exceptions:: + IllegalMonitorStateException(); } } - catch (IllegalMonitorStateException& ex) + catch (activemq::exceptions::IllegalMonitorStateException&) { node->waitStatus = Node::CANCELLED; throw; @@ -1349,8 +1358,9 @@ namespace util { REINTERRUPT = 1, // Re-interrupt thread on exit from a wait call. - THROW_IE = -1 // Throw a new InterruptedException on wait - // call exit. + THROW_IE = -1 // Throw a new + // activemq::exceptions::InterruptedException + // on wait call exit. }; private: @@ -1379,9 +1389,10 @@ namespace util { if (Thread::interrupted()) { - throw InterruptedException(__FILE__, - __LINE__, - "Thread was interrupted"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Thread was interrupted"); } Node* node = addConditionWaiter(); @@ -1439,9 +1450,10 @@ namespace util { if (Thread::interrupted()) { - throw InterruptedException(__FILE__, - __LINE__, - "Thread was interrupted"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Thread was interrupted"); } Node* node = addConditionWaiter(); int savedState = impl->fullyRelease(node); @@ -1489,9 +1501,10 @@ namespace util long long nanosTimeout = unit.toNanos(time); if (Thread::interrupted()) { - throw InterruptedException(__FILE__, - __LINE__, - "Thread was interrupted"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Thread was interrupted"); } Node* node = addConditionWaiter(); int savedState = impl->fullyRelease(node); @@ -1542,9 +1555,10 @@ namespace util long long abstime = deadline.getTime(); if (Thread::interrupted()) { - throw InterruptedException(__FILE__, - __LINE__, - "Thread was interrupted"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Thread was interrupted"); } Node* node = addConditionWaiter(); int savedState = impl->fullyRelease(node); @@ -1591,7 +1605,8 @@ namespace util { if (!impl->isHeldExclusively()) { - throw IllegalMonitorStateException(); + throw activemq::exceptions:: + IllegalMonitorStateException(); } Node* first = head; if (first != NULL) @@ -1604,7 +1619,8 @@ namespace util { if (!impl->isHeldExclusively()) { - throw IllegalMonitorStateException(); + throw activemq::exceptions:: + IllegalMonitorStateException(); } Node* first = head; if (first != NULL) @@ -1623,7 +1639,8 @@ namespace util { if (!impl->isHeldExclusively()) { - throw IllegalMonitorStateException(); + throw activemq::exceptions:: + IllegalMonitorStateException(); } for (Node* w = head; w != NULL; w = w->nextWaiter) @@ -1641,7 +1658,8 @@ namespace util { if (!impl->isHeldExclusively()) { - throw IllegalMonitorStateException(); + throw activemq::exceptions:: + IllegalMonitorStateException(); } int n = 0; @@ -1661,7 +1679,8 @@ namespace util { if (!impl->isHeldExclusively()) { - throw IllegalMonitorStateException(); + throw activemq::exceptions:: + IllegalMonitorStateException(); } ArrayList* list = new ArrayList(); @@ -1832,10 +1851,10 @@ namespace util } /** - * Throws InterruptedException, re-interrupts current thread, or - * does nothing, depending on mode passed, abstract the logic - * needed for all the interruptible wait methods out into a - * single place. + * Throws activemq::exceptions::InterruptedException, + * re-interrupts current thread, or does nothing, depending on + * mode passed, abstract the logic needed for all the + * interruptible wait methods out into a single place. * * @param interruptMode * indicates what action is needed for interruption @@ -1845,9 +1864,10 @@ namespace util { if (interruptMode == THROW_IE) { - throw InterruptedException(__FILE__, - __LINE__, - "Thread was Interrupted"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Thread was Interrupted"); } else if (interruptMode == REINTERRUPT) { @@ -1900,31 +1920,41 @@ bool AbstractQueuedSynchronizer::compareAndSetState(int expect, int update) //////////////////////////////////////////////////////////////////////////////// bool AbstractQueuedSynchronizer::tryAcquire(int arg DECAF_UNUSED) { - throw UnsupportedOperationException(); + throw activemq::exceptions::UnsupportedOperationException(__FILE__, + __LINE__, + ""); } //////////////////////////////////////////////////////////////////////////////// bool AbstractQueuedSynchronizer::tryRelease(int arg DECAF_UNUSED) { - throw UnsupportedOperationException(); + throw activemq::exceptions::UnsupportedOperationException(__FILE__, + __LINE__, + ""); } //////////////////////////////////////////////////////////////////////////////// int AbstractQueuedSynchronizer::tryAcquireShared(int arg DECAF_UNUSED) { - throw UnsupportedOperationException(); + throw activemq::exceptions::UnsupportedOperationException(__FILE__, + __LINE__, + ""); } //////////////////////////////////////////////////////////////////////////////// bool AbstractQueuedSynchronizer::tryReleaseShared(int arg DECAF_UNUSED) { - throw UnsupportedOperationException(); + throw activemq::exceptions::UnsupportedOperationException(__FILE__, + __LINE__, + ""); } //////////////////////////////////////////////////////////////////////////////// bool AbstractQueuedSynchronizer::isHeldExclusively() const { - throw UnsupportedOperationException(); + throw activemq::exceptions::UnsupportedOperationException(__FILE__, + __LINE__, + ""); } //////////////////////////////////////////////////////////////////////////////// @@ -1952,9 +1982,10 @@ void AbstractQueuedSynchronizer::acquireInterruptibly(int arg) { if (Thread::interrupted()) { - throw InterruptedException(__FILE__, - __LINE__, - "Thread interrupted before acquisition"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Thread interrupted before acquisition"); } if (!tryAcquire(arg)) @@ -1969,9 +2000,10 @@ bool AbstractQueuedSynchronizer::tryAcquireNanos(int arg, { if (Thread::interrupted()) { - throw InterruptedException(__FILE__, - __LINE__, - "Thread interrupted before acquisition"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Thread interrupted before acquisition"); } return tryAcquire(arg) || this->impl->doAcquireNanos(arg, nanosTimeout); @@ -2008,9 +2040,10 @@ void AbstractQueuedSynchronizer::acquireSharedInterruptibly(int arg) { if (Thread::interrupted()) { - throw InterruptedException(__FILE__, - __LINE__, - "Thread interrupted before acquisition"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Thread interrupted before acquisition"); } if (tryAcquireShared(arg) < 0) @@ -2025,9 +2058,10 @@ bool AbstractQueuedSynchronizer::tryAcquireSharedNanos(int arg, { if (Thread::interrupted()) { - throw InterruptedException(__FILE__, - __LINE__, - "Thread interrupted before acquisition"); + throw activemq::exceptions::InterruptedException( + __FILE__, + __LINE__, + "Thread interrupted before acquisition"); } return tryAcquireShared(arg) >= 0 || @@ -2072,9 +2106,10 @@ bool AbstractQueuedSynchronizer::isQueued(Thread* thread) const { if (thread == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Passed in thread was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Passed in thread was NULL"); } for (Node* p = this->impl->tail.get(); p != NULL; p = p->prev) @@ -2167,9 +2202,10 @@ bool AbstractQueuedSynchronizer::owns(const ConditionObject* condition) const { if (condition == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Condition Pointer arg was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Condition Pointer arg was NULL"); } return condition->isOwnedBy(this); } @@ -2180,7 +2216,9 @@ bool AbstractQueuedSynchronizer::hasWaiters( { if (!owns(condition)) { - throw IllegalArgumentException(__FILE__, __LINE__, "Not owner"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Not owner"); } return condition->hasWaiters(); } @@ -2191,7 +2229,9 @@ int AbstractQueuedSynchronizer::getWaitQueueLength( { if (!owns(condition)) { - throw IllegalArgumentException(__FILE__, __LINE__, "Not owner"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Not owner"); } return condition->getWaitQueueLength(); } @@ -2202,7 +2242,9 @@ Collection* AbstractQueuedSynchronizer::getWaitingThreads( { if (!owns(condition)) { - throw IllegalArgumentException(__FILE__, __LINE__, "Not owner"); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Not owner"); } return condition->getWaitingThreads(); } diff --git a/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.h b/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.h index 168c4baff..3f11595b8 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.h @@ -24,6 +24,7 @@ #include #include #include +#include namespace decaf { @@ -153,7 +154,7 @@ namespace util * Argument passed to tryAcquire, value is not interpreted * by this class. * - * @throws InterruptedException if the calling Thread is + * @throws std::runtime_error if the calling Thread is * interrupted. */ void acquireInterruptibly(int arg); @@ -169,7 +170,7 @@ namespace util * Argument passed to tryAcquireShared, value is not * interpreted by this class. * - * @throws InterruptedException if the calling Thread is + * @throws std::runtime_error if the calling Thread is * interrupted. */ void acquireSharedInterruptibly(int arg); @@ -234,11 +235,11 @@ namespace util * @return a Collection pointer that contains waiting threads on * given ConditionObject. The caller owns the returned pointer. * - * @throws NullPointerException if the ConditionObject pointer + * @throws std::logic_error if the ConditionObject pointer * is NULL. - * @throws IllegalArgumentException if the ConditionObject is + * @throws std::invalid_argument if the ConditionObject is * not associated with this Synchronizer. - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * hold exclusive synchronization. */ Collection* getWaitingThreads( @@ -255,11 +256,11 @@ namespace util * * @return an estimate of the number of waiting threads. * - * @throws NullPointerException if the ConditionObject pointer + * @throws std::logic_error if the ConditionObject pointer * is NULL. - * @throws IllegalArgumentException if the ConditionObject is + * @throws std::invalid_argument if the ConditionObject is * not associated with this Synchronizer. - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * hold exclusive synchronization. */ int getWaitQueueLength( @@ -285,11 +286,11 @@ namespace util * * @return true if the condition object has waiting threads. * - * @throws NullPointerException if the ConditionObject pointer + * @throws std::logic_error if the ConditionObject pointer * is NULL. - * @throws IllegalArgumentException if the ConditionObject is + * @throws std::invalid_argument if the ConditionObject is * not associated with this Synchronizer. - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * hold exclusive synchronization. */ bool hasWaiters( @@ -302,7 +303,7 @@ namespace util * * @return true if the given thread is in the wait Queue. * - * @throws NullPointerException if the thread pointer is NULL. + * @throws std::logic_error if the thread pointer is NULL. */ bool isQueued(decaf::lang::Thread* thread) const; @@ -313,7 +314,7 @@ namespace util * @return true if the ConditionObject uses this Synchronizer as * its lock. * - * @throws NullPointerException if the condition pointer is + * @throws std::logic_error if the condition pointer is * NULL. */ bool owns(const AbstractQueuedSynchronizer::ConditionObject* @@ -376,7 +377,7 @@ namespace util * * @return true if the acquire succeeded, false otherwise. * - * @throws InterruptedException if the calling thread is + * @throws std::runtime_error if the calling thread is * interrupted. */ bool tryAcquireNanos(int arg, long long nanos); @@ -397,7 +398,7 @@ namespace util * * @return true if the acquire succeeded, false otherwise. * - * @throws InterruptedException if the calling thread is + * @throws std::runtime_error if the calling thread is * interrupted. */ bool tryAcquireSharedNanos(int arg, long long nanos); @@ -444,7 +445,7 @@ namespace util * @return true if this synchronization is held exclusively by * the current thread. * - * @throws UnsupportedOperationException if Condition objects + * @throws std::logic_error if Condition objects * are not supported. */ virtual bool isHeldExclusively() const; @@ -468,9 +469,9 @@ namespace util * * @return true if the acquire succeeded, false otherwise. * - * @throws IllegalMonitorStateException if the acquire places + * @throws std::logic_error if the acquire places * the object in an invalid state. - * @throws UnsupportedOperationException if exclusive mode is + * @throws std::logic_error if exclusive mode is * not supported. */ virtual bool tryAcquire(int arg); @@ -496,9 +497,9 @@ namespace util * did succeed but no additional shared mode acquires can, or a * positive number if success and future calls amy also succeed. * - * @throws IllegalMonitorStateException if the acquire places + * @throws std::logic_error if the acquire places * the object in an invalid state. - * @throws UnsupportedOperationException if shared mode is not + * @throws std::logic_error if shared mode is not * supported. */ virtual int tryAcquireShared(int arg); @@ -518,9 +519,9 @@ namespace util * such that waiting threads can now attempt to acquire it, * false if not fully released. * - * @throws IllegalMonitorStateException if the release places + * @throws std::logic_error if the release places * the object in an invalid state. - * @throws UnsupportedOperationException if exclusive mode is + * @throws std::logic_error if exclusive mode is * not supported. */ virtual bool tryRelease(int arg); @@ -540,9 +541,9 @@ namespace util * such that waiting threads can now attempt to acquire it, * false if not fully released. * - * @throws IllegalMonitorStateException if the release places + * @throws std::logic_error if the release places * the object in an invalid state. - * @throws UnsupportedOperationException if shared mode is not + * @throws std::logic_error if shared mode is not * supported. */ virtual bool tryReleaseShared(int arg); diff --git a/activemq-cpp/src/main/decaf/util/concurrent/locks/Condition.h b/activemq-cpp/src/main/decaf/util/concurrent/locks/Condition.h index 3b65b969d..26f5982e2 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/locks/Condition.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/locks/Condition.h @@ -20,11 +20,10 @@ #include -#include -#include -#include +#include #include #include +#include namespace decaf { @@ -183,7 +182,7 @@ namespace util * * is interrupted while waiting and interruption of thread * suspension is supported, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. It is not specified, in the * first case, whether or not the test for interruption occurs * before the lock is released. @@ -194,7 +193,7 @@ namespace util * with this Condition when this method is called. It is up to * the implementation to determine if this is the case and if * not, how to respond. Typically, an exception will be thrown - * (such as IllegalMonitorStateException) and the implementation + * (such as std::logic_error) and the implementation * must document that fact. * * An implementation can favor responding to an interrupt over @@ -202,15 +201,15 @@ namespace util * the implementation must ensure that the signal is redirected * to another waiting thread, if there is one. * - * @throws RuntimeException + * @throws Exception * if an unexpected error occurs while trying to wait on * the Condition. * - * @throws InterruptedException + * @throws std::runtime_error * if the current thread is interrupted (and * interruption of thread suspension is supported) * - * @throws IllegalMonitorStateException + * @throws std::logic_error * if the caller is not the lock owner. */ virtual void await() = 0; @@ -247,14 +246,14 @@ namespace util * with this Condition when this method is called. It is up to * the implementation to determine if this is the case and if * not, how to respond. Typically, an exception will be thrown - * (such as IllegalMonitorStateException) and the implementation + * (such as std::logic_error) and the implementation * must document that fact. * - * @throws RuntimeException + * @throws Exception * if an unexpected error occurs while trying to wait on * the Condition. * - * @throws IllegalMonitorStateException + * @throws std::logic_error * if the caller is not the lock owner. */ virtual void awaitUninterruptibly() = 0; @@ -290,7 +289,7 @@ namespace util * * is interrupted while waiting and interruption of thread * suspension is supported, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. It is not specified, in the * first case, whether or not the test for interruption occurs * before the lock is released. @@ -325,7 +324,7 @@ namespace util * with this Condition when this method is called. It is up to * the implementation to determine if this is the case and if * not, how to respond. Typically, an exception will be thrown - * (such as IllegalMonitorStateException) and the implementation + * (such as std::logic_error) and the implementation * must document that fact. * * An implementation can favor responding to an interrupt over @@ -343,15 +342,15 @@ namespace util * method to finish waiting out the desired time. A value less * than or equal to zero indicates that no time remains. * - * @throws RuntimeException + * @throws Exception * if an unexpected error occurs while trying to wait on * the Condition. * - * @throws InterruptedException + * @throws std::runtime_error * if the current thread is interrupted (and * interruption of thread suspension is supported) * - * @throws IllegalMonitorStateException + * @throws std::logic_error * if the caller is not the lock owner. */ virtual long long awaitNanos(long long nanosTimeout) = 0; @@ -369,15 +368,15 @@ namespace util * @return false if the waiting time detectably elapsed before * return from the method, else true * - * @throws RuntimeException + * @throws Exception * if an unexpected error occurs while trying to wait on * the Condition. * - * @throws InterruptedException + * @throws std::runtime_error * if the current thread is interrupted (and * interruption of thread suspension is supported) * - * @throws IllegalMonitorStateException + * @throws std::logic_error * if the caller is not the lock owner. */ virtual bool await(long long time, const TimeUnit& unit) = 0; @@ -413,7 +412,7 @@ namespace util * * is interrupted while waiting and interruption of thread * suspension is supported, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. It is not specified, in the * first case, whether or not the test for interruption occurs * before the lock is released. @@ -438,7 +437,7 @@ namespace util * with this Condition when this method is called. It is up to * the implementation to determine if this is the case and if * not, how to respond. Typically, an exception will be thrown - * (such as IllegalMonitorStateException) and the implementation + * (such as std::logic_error) and the implementation * must document that fact. * * An implementation can favor responding to an interrupt over @@ -452,15 +451,15 @@ namespace util * @return false if the deadline has elapsed upon return, else * true * - * @throws RuntimeException + * @throws Exception * if an unexpected error occurs while trying to wait on * the Condition. * - * @throws InterruptedException + * @throws std::runtime_error * if the current thread is interrupted (and * interruption of thread suspension is supported) * - * @throws IllegalMonitorStateException + * @throws std::logic_error * if the caller is not the lock owner. */ virtual bool awaitUntil(const Date& deadline) = 0; @@ -472,7 +471,7 @@ namespace util * selected for waking up. That thread must then re-acquire the * lock before returning from await. * - * @throws RuntimeException + * @throws Exception * if an unexpected error occurs while trying to wait on * the Condition. */ @@ -485,7 +484,7 @@ namespace util * all woken up. Each thread must re-acquire the lock before it * can return from await. * - * @throws RuntimeException + * @throws Exception * if an unexpected error occurs while trying to wait on * the Condition. */ diff --git a/activemq-cpp/src/main/decaf/util/concurrent/locks/Lock.h b/activemq-cpp/src/main/decaf/util/concurrent/locks/Lock.h index baa708724..9eaab2718 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/locks/Lock.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/locks/Lock.h @@ -20,9 +20,8 @@ #include -#include -#include #include +#include namespace decaf { @@ -131,7 +130,7 @@ namespace util * circumstances and the exception type must be documented by * that Lock implementation. * - * @throws RuntimeException if an error occurs while acquiring + * @throws Exception if an error occurs while acquiring * the lock. */ virtual void lock() = 0; @@ -155,7 +154,7 @@ namespace util * * is interrupted while acquiring the lock, and interruption * of lock acquisition is supported, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. * * Implementation Considerations @@ -175,9 +174,9 @@ namespace util * circumstances and the exception type must be documented by * that Lock implementation. * - * @throws RuntimeException if an error occurs while acquiring + * @throws Exception if an error occurs while acquiring * the lock. - * @throws InterruptedException + * @throws std::runtime_error * if the current thread is interrupted while acquiring * the lock (and interruption of lock acquisition is supported). */ @@ -209,7 +208,7 @@ namespace util * * @return true if the lock was acquired and false otherwise * - * @throws RuntimeException if an error occurs while acquiring + * @throws Exception if an error occurs while acquiring * the lock. */ virtual bool tryLock() = 0; @@ -236,7 +235,7 @@ namespace util * * is interrupted while acquiring the lock, and interruption * of lock acquisition is supported, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. * * If the specified waiting time elapses then the value false is @@ -268,9 +267,9 @@ namespace util * @return true if the lock was acquired and false if the * waiting time elapsed before the lock was acquired * - * @throws RuntimeException if an error occurs while acquiring + * @throws Exception if an error occurs while acquiring * the lock. - * @throws InterruptedException + * @throws std::runtime_error * if the current thread is interrupted while acquiring * the lock (and interruption of lock acquisition is supported) */ @@ -287,9 +286,9 @@ namespace util * restriction is violated. Any restrictions and the exception * type must be documented by that Lock implementation. * - * @throws RuntimeException if an error occurs while acquiring + * @throws Exception if an error occurs while acquiring * the lock. - * @throws IllegalMonitorStateException if the current thread is + * @throws std::logic_error if the current thread is * not the owner of the lock. */ virtual void unlock() = 0; @@ -310,9 +309,9 @@ namespace util * caller must delete the returned Condition object when done * with it. * - * @throws RuntimeException if an error occurs while creating + * @throws Exception if an error occurs while creating * the Condition. - * @throws UnsupportedOperationException + * @throws std::logic_error * if this Lock implementation does not support * conditions */ diff --git a/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.cpp b/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.cpp index 443f3e131..92337e4ea 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.cpp +++ b/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.cpp @@ -17,16 +17,17 @@ #include +#include #include -#include -#include #include +#include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::locks; @@ -90,7 +91,7 @@ namespace util // Check for overflow of the state counter. if (nextc < 0) { - throw new RuntimeException( + throw activemq::exceptions::RuntimeException( __FILE__, __LINE__, "Maximum lock count exceeded"); @@ -136,7 +137,8 @@ namespace util if (Thread::currentThread() != getExclusiveOwnerThread()) { - throw IllegalMonitorStateException(); + throw activemq::exceptions:: + IllegalMonitorStateException(); } bool free = false; @@ -241,7 +243,7 @@ namespace util // Check for overflow of the lock sstate variable. if (nextc < 0) { - throw new RuntimeException( + throw activemq::exceptions::RuntimeException( __FILE__, __LINE__, "Maximum lock count exceeded"); @@ -395,9 +397,10 @@ bool ReentrantLock::hasQueuedThread(decaf::lang::Thread* thread) const { if (thread == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The thread to check was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The thread to check was NULL"); } return this->sync->isQueued(thread); @@ -408,9 +411,10 @@ int ReentrantLock::getWaitQueueLength(Condition* condition) const { if (condition == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The Condition to check was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The Condition to check was NULL"); } const AbstractQueuedSynchronizer::ConditionObject* cond = @@ -419,9 +423,8 @@ int ReentrantLock::getWaitQueueLength(Condition* condition) const if (cond == NULL) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Condition is not associated with this Lock"); } @@ -433,9 +436,10 @@ bool ReentrantLock::hasWaiters(Condition* condition) const { if (condition == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The Condition to check was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The Condition to check was NULL"); } const AbstractQueuedSynchronizer::ConditionObject* cond = @@ -444,9 +448,8 @@ bool ReentrantLock::hasWaiters(Condition* condition) const if (cond == NULL) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Condition is not associated with this Lock"); } @@ -459,9 +462,10 @@ Collection* ReentrantLock::getWaitingThreads( { if (condition == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The Condition to check was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The Condition to check was NULL"); } const AbstractQueuedSynchronizer::ConditionObject* cond = @@ -470,9 +474,8 @@ Collection* ReentrantLock::getWaitingThreads( if (cond == NULL) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Condition is not associated with this Lock"); } diff --git a/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.h b/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.h index 98085a045..39fceddb4 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantLock.h @@ -22,6 +22,7 @@ #include #include +#include namespace decaf { @@ -136,7 +137,7 @@ namespace util * dormant until the lock has been acquired, at which time the * lock hold count is set to one. * - * @throws RuntimeException if an error occurs while acquiring + * @throws Exception if an error occurs while acquiring * the lock. */ virtual void lock(); @@ -167,16 +168,16 @@ namespace util * or * * is interrupted while acquiring the lock, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. * * In this implementation, as this method is an explicit * interruption point, preference is given to responding to the * interrupt over normal or reentrant acquisition of the lock. * - * @throws RuntimeException if an error occurs while acquiring + * @throws Exception if an error occurs while acquiring * the lock. - * @throws InterruptedException + * @throws std::runtime_error * if the current thread is interrupted while acquiring * the lock (and interruption of lock acquisition is supported). */ @@ -205,7 +206,7 @@ namespace util * * @return true if the lock was acquired and false otherwise * - * @throws RuntimeException if an error occurs while acquiring + * @throws Exception if an error occurs while acquiring * the lock. */ virtual bool tryLock(); @@ -247,7 +248,7 @@ namespace util * or * * is interrupted while acquiring the lock, * - * then InterruptedException is thrown and the current thread's + * then std::runtime_error is thrown and the current thread's * interrupted status is cleared. * * If the specified waiting time elapses then the value false is @@ -267,9 +268,9 @@ namespace util * @return true if the lock was acquired and false if the * waiting time elapsed before the lock was acquired * - * @throws RuntimeException if an error occurs while acquiring + * @throws Exception if an error occurs while acquiring * the lock. - * @throws InterruptedException + * @throws std::runtime_error * if the current thread is interrupted while acquiring * the lock (and interruption of lock acquisition is supported) */ @@ -281,9 +282,9 @@ namespace util * If the current thread is the holder of this lock then the * hold count is decremented. If the hold count is now zero then * the lock is released. If the current thread is not the holder - * of this lock then IllegalMonitorStateException is thrown. + * of this lock then std::logic_error is thrown. * - * @throws RuntimeException if an error occurs while acquiring + * @throws Exception if an error occurs while acquiring * the lock. */ virtual void unlock(); @@ -296,13 +297,13 @@ namespace util * * * If this lock is not held when any of the Condition * waiting or signalling methods are called, then an - * IllegalMonitorStateException is thrown. + * std::logic_error is thrown. * * When the condition waiting methods are called the lock is * released and, before they return, the lock is reacquired and * the lock hold count restored to what it was when the method * was called. * * If a thread is interrupted while waiting then the wait - * will terminate, an InterruptedException will be thrown, and + * will terminate, an std::runtime_error will be thrown, and * the thread's interrupted status will be cleared. * * Waiting threads are signaled in FIFO order. * * The ordering of lock reacquisition for threads returning @@ -311,9 +312,9 @@ namespace util * specified, but for fair locks favors those threads that * have been waiting the longest. * - * @throws RuntimeException if an error occurs while creating + * @throws Exception if an error occurs while creating * the Condition. - * @throws UnsupportedOperationException + * @throws std::logic_error * if this Lock implementation does not support * conditions */ @@ -449,11 +450,11 @@ namespace util * * @return an estimate of the number of waiting threads. * - * @throws NullPointerException if the ConditionObject pointer + * @throws std::logic_error if the ConditionObject pointer * is NULL. - * @throws IllegalArgumentException if the ConditionObject is + * @throws std::invalid_argument if the ConditionObject is * not associated with this Synchronizer. - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * hold exclusive synchronization. */ int getWaitQueueLength(Condition* condition) const; @@ -465,11 +466,11 @@ namespace util * * @return true if the condition object has waiting threads. * - * @throws NullPointerException if the ConditionObject pointer + * @throws std::logic_error if the ConditionObject pointer * is NULL. - * @throws IllegalArgumentException if the ConditionObject is + * @throws std::invalid_argument if the ConditionObject is * not associated with this Lock. - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * hold exclusive synchronization. */ bool hasWaiters(Condition* condition) const; @@ -485,7 +486,7 @@ namespace util * Lock object. Because of cancellations this method can return * true but the given Thread is not in the Queue afterwards. * - * @throws NullPointerException if the given thread is NULL. + * @throws std::logic_error if the given thread is NULL. */ bool hasQueuedThread(decaf::lang::Thread* thread) const; @@ -498,11 +499,11 @@ namespace util * @return a Collection pointer that contains waiting threads on * given Condition object. The caller owns the returned pointer. * - * @throws NullPointerException if the ConditionObject pointer + * @throws std::logic_error if the ConditionObject pointer * is NULL. - * @throws IllegalArgumentException if the ConditionObject is + * @throws std::invalid_argument if the ConditionObject is * not associated with this Synchronizer. - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * hold exclusive synchronization. */ decaf::util::Collection* diff --git a/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp b/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp index 1d1414350..b3030397f 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp +++ b/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp @@ -21,13 +21,15 @@ #include #include #include -#include #include #include +#include +#include +#include + using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::locks; @@ -145,7 +147,7 @@ class Sync : public AbstractQueuedSynchronizer { if (!this->isHeldExclusively()) { - throw IllegalMonitorStateException( + throw activemq::exceptions::IllegalMonitorStateException( __FILE__, __LINE__, "Sync lock not held exclusively"); @@ -186,9 +188,10 @@ class Sync : public AbstractQueuedSynchronizer } if (w + exclusiveCount(acquires) > MAX_COUNT) { - throw new RuntimeException(__FILE__, - __LINE__, - "Maximum lock count exceeded"); + throw activemq::exceptions::RuntimeException(__FILE__, + __LINE__, + "Maximum lock " + "count exceeded"); } // Reentrant acquire setState(c + acquires); @@ -227,10 +230,11 @@ class Sync : public AbstractQueuedSynchronizer readHolds.remove(); if (count <= 0) { - throw IllegalMonitorStateException( + throw activemq::exceptions::IllegalMonitorStateException( __FILE__, __LINE__, - "attempt to unlock read lock, not locked by current " + "attempt to unlock read lock, not locked by " + "current " "thread"); } } @@ -324,7 +328,7 @@ class Sync : public AbstractQueuedSynchronizer { if (firstReaderHoldCount > 0) { - throw Exception( + throw activemq::exceptions::RuntimeException( __FILE__, __LINE__, "Read lock should not be aquired reentrantlly."); @@ -346,9 +350,10 @@ class Sync : public AbstractQueuedSynchronizer } if (sharedCount(c) == MAX_COUNT) { - throw Exception(__FILE__, - __LINE__, - "Maximum lock count exceeded"); + throw activemq::exceptions::RuntimeException(__FILE__, + __LINE__, + "Maximum lock " + "count exceeded"); } if (compareAndSetState(c, c + SHARED_UNIT)) { @@ -390,9 +395,10 @@ class Sync : public AbstractQueuedSynchronizer } if (w == MAX_COUNT) { - throw new Exception(__FILE__, - __LINE__, - "Maximum lock count exceeded"); + throw activemq::exceptions::RuntimeException(__FILE__, + __LINE__, + "Maximum lock " + "count exceeded"); } } if (!compareAndSetState(c, c + 1)) @@ -421,9 +427,10 @@ class Sync : public AbstractQueuedSynchronizer int r = sharedCount(c); if (r == MAX_COUNT) { - throw Exception(__FILE__, - __LINE__, - "Maximum lock count exceeded"); + throw activemq::exceptions::RuntimeException(__FILE__, + __LINE__, + "Maximum lock " + "count exceeded"); } if (compareAndSetState(c, c + SHARED_UNIT)) { @@ -638,7 +645,8 @@ class ReadLock : public decaf::util::concurrent::locks::Lock * point, preference is given to responding to the interrupt over normal * or reentrant acquisition of the lock. * - * @throws InterruptedException if the current thread is interrupted + * @throws activemq::exceptions::InterruptedException if the current + * thread is interrupted */ void lockInterruptibly() { @@ -707,8 +715,8 @@ class ReadLock : public decaf::util::concurrent::locks::Lock *

    *
  • has its interrupted status set on entry to this method; or *
  • is interrupted while acquiring the read lock, - *
then InterruptedException is thrown and the current thread's - * interrupted status is cleared. + * then activemq::exceptions::InterruptedException is thrown + * and the current thread's interrupted status is cleared. * *

If the specified waiting time elapses then the value * {@code false} is returned. If the time is less than or @@ -724,7 +732,8 @@ class ReadLock : public decaf::util::concurrent::locks::Lock * * @return {@code true} if the read lock was acquired * - * @throws InterruptedException if the current thread is interrupted + * @throws activemq::exceptions::InterruptedException if the current + * thread is interrupted */ virtual bool tryLock(long long timeout, const TimeUnit& unit) { @@ -743,13 +752,13 @@ class ReadLock : public decaf::util::concurrent::locks::Lock } /** - * Throws UnsupportedOperationException because ReadLocks do not support - * conditions. - * @throws UnsupportedOperationException always + * Throws activemq::exceptions::IllegalStateException because + * ReadLocks do not support conditions. + * @throws activemq::exceptions::IllegalStateException always */ virtual Condition* newCondition() { - throw new UnsupportedOperationException(); + throw activemq::exceptions::UnsupportedOperationException(); } /** @@ -837,14 +846,15 @@ class WriteLock : public decaf::util::concurrent::locks::Lock *

  • is interrupted while acquiring the write lock, * * - * then InterruptedException is thrown and the current thread's - * interrupted status is cleared. + * then activemq::exceptions::InterruptedException is thrown and the + * current thread's interrupted status is cleared. * *

    In this implementation, as this method is an explicit interruption * point, preference is given to responding to the interrupt over normal or * reentrant acquisition of the lock. * - * @throws InterruptedException if the current thread is interrupted + * @throws activemq::exceptions::InterruptedException if the current + * thread is interrupted */ virtual void lockInterruptibly() { @@ -924,8 +934,8 @@ class WriteLock : public decaf::util::concurrent::locks::Lock *

  • is interrupted while acquiring the write lock, * * - * then InterruptedException is thrown and the current - * thread's interrupted status is cleared. + * then activemq::exceptions::InterruptedException is thrown and the + * current thread's interrupted status is cleared. * *

    If the specified waiting time elapses then the value * false is returned. If the time is less than or @@ -944,7 +954,8 @@ class WriteLock : public decaf::util::concurrent::locks::Lock * current thread; and false if the waiting time * elapsed before the lock could be acquired. * - * @throws InterruptedException if the current thread is interrupted + * @throws activemq::exceptions::InterruptedException if the current + * thread is interrupted */ virtual bool tryLock(long long timeout, const TimeUnit& unit) { @@ -957,10 +968,10 @@ class WriteLock : public decaf::util::concurrent::locks::Lock *

    If the current thread is the holder of this lock then the hold * count is decremented. If the hold count is now zero then the lock * is released. If the current thread is not the holder of this lock - * then IllegalMonitorStateException is thrown. + * then activemq::exceptions::IllegalStateException is thrown. * - * @throws IllegalMonitorStateException if the current thread does not - * hold this lock. + * @throws activemq::exceptions::IllegalStateException if the + * current thread does not hold this lock. */ virtual void unlock() { @@ -976,22 +987,22 @@ class WriteLock : public decaf::util::concurrent::locks::Lock * *

      *
    • If this write lock is not held when any Condition method is called - * then an IllegalMonitorStateException is thrown. (Read locks are - * held independently of write locks, so are not checked or affected. - * However it is essentially always an error to invoke a condition waiting - * method when the current thread has also acquired read locks, since - * other threads that could unblock it will not be able to acquire the write - * lock.) - *
    • When the condition waiting methods are called the write lock is - * released and, before they return, the write lock is reacquired and the - * lock hold count restored to what it was when the method was called. - *
    • If a thread is interrupted while waiting then the wait will - * terminate, an InterruptedException will be thrown, and the thread's - * interrupted status will be cleared.
    • Waiting threads are signalled in - * FIFO order.
    • The ordering of lock reacquisition for threads returning - * from waiting methods is the same as for threads initially acquiring the - * lock, which is in the default case not specified, but for fair - * locks favors those threads that have been waiting the longest. + * then an activemq::exceptions::IllegalStateException is thrown. + * (Read locks are held independently of write locks, so are not checked or + * affected. However it is essentially always an error to invoke a condition + * waiting method when the current thread has also acquired read locks, + * since other threads that could unblock it will not be able to acquire the + * write lock.)
    • When the condition waiting methods are called the write + * lock is released and, before they return, the write lock is reacquired + * and the lock hold count restored to what it was when the method was + * called.
    • If a thread is interrupted while waiting then the wait will + * terminate, an activemq::exceptions::InterruptedException will be + * thrown, and the thread's interrupted status will be cleared.
    • Waiting + * threads are signalled in FIFO order.
    • The ordering of lock + * reacquisition for threads returning from waiting methods is the same as + * for threads initially acquiring the lock, which is in the default case + * not specified, but for fair locks favors those threads that have + * been waiting the longest. *
    * * @return the Condition object @@ -1214,9 +1225,10 @@ bool ReentrantReadWriteLock::hasWaiters(Condition* condition) const { if (condition == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The Condition to check was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The Condition to check was NULL"); } const AbstractQueuedSynchronizer::ConditionObject* cond = @@ -1225,9 +1237,8 @@ bool ReentrantReadWriteLock::hasWaiters(Condition* condition) const if (cond == NULL) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Condition is not associated with this Lock"); } @@ -1239,9 +1250,10 @@ int ReentrantReadWriteLock::getWaitQueueLength(Condition* condition) const { if (condition == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The Condition to check was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The Condition to check was NULL"); } const AbstractQueuedSynchronizer::ConditionObject* cond = @@ -1250,9 +1262,8 @@ int ReentrantReadWriteLock::getWaitQueueLength(Condition* condition) const if (cond == NULL) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Condition is not associated with this Lock"); } @@ -1265,9 +1276,10 @@ Collection* ReentrantReadWriteLock::getWaitingThreads( { if (condition == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The Condition to check was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The Condition to check was NULL"); } const AbstractQueuedSynchronizer::ConditionObject* cond = @@ -1276,9 +1288,8 @@ Collection* ReentrantReadWriteLock::getWaitingThreads( if (cond == NULL) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Condition is not associated with this Lock"); } diff --git a/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.h b/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.h index 763b804ee..7da56666b 100644 --- a/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.h +++ b/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace decaf { @@ -147,11 +148,11 @@ namespace util * * @return true if there are any waiting threads * - * @throws NullPointerException if the ConditionObject pointer + * @throws std::logic_error if the ConditionObject pointer * is NULL. - * @throws IllegalArgumentException if the ConditionObject is + * @throws std::invalid_argument if the ConditionObject is * not associated with this Lock. - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * hold exclusive synchronization. */ bool hasWaiters(Condition* condition) const; @@ -166,11 +167,11 @@ namespace util * * @return an estimate of the number of waiting threads. * - * @throws NullPointerException if the ConditionObject pointer + * @throws std::logic_error if the ConditionObject pointer * is NULL. - * @throws IllegalArgumentException if the ConditionObject is + * @throws std::invalid_argument if the ConditionObject is * not associated with this Synchronizer. - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * hold exclusive synchronization. */ int getWaitQueueLength(Condition* condition) const; @@ -212,7 +213,7 @@ namespace util * @return true if the given thread is queued waiting for this * lock * - * @throws NullPointerException if the thread is NULL. + * @throws std::logic_error if the thread is NULL. */ bool hasQueuedThread(decaf::lang::Thread* thread) const; @@ -237,11 +238,11 @@ namespace util * @return a Collection pointer that contains waiting threads on * given Condition object. The caller owns the returned pointer. * - * @throws NullPointerException if the ConditionObject pointer + * @throws std::logic_error if the ConditionObject pointer * is NULL. - * @throws IllegalArgumentException if the ConditionObject is + * @throws std::invalid_argument if the ConditionObject is * not associated with this Synchronizer. - * @throws IllegalMonitorStateException if the caller does not + * @throws std::logic_error if the caller does not * hold exclusive synchronization. */ decaf::util::Collection* diff --git a/activemq-cpp/src/main/decaf/util/logging/Handler.cpp b/activemq-cpp/src/main/decaf/util/logging/Handler.cpp index da43f862d..a31ac4c95 100644 --- a/activemq-cpp/src/main/decaf/util/logging/Handler.cpp +++ b/activemq-cpp/src/main/decaf/util/logging/Handler.cpp @@ -17,9 +17,12 @@ #include "Handler.h" +#include #include #include #include +#include +#include using namespace std; using namespace decaf; @@ -48,7 +51,7 @@ void Handler::setFormatter(Formatter* formatter) { if (formatter == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "The Formatter cannot be set to NULL."); @@ -62,7 +65,7 @@ void Handler::setErrorManager(ErrorManager* errorManager) { if (errorManager == NULL) { - throw decaf::lang::exceptions::NullPointerException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Error Manager cannot be set to NULL."); diff --git a/activemq-cpp/src/main/decaf/util/logging/Handler.h b/activemq-cpp/src/main/decaf/util/logging/Handler.h index 8b4224362..3f54569bd 100644 --- a/activemq-cpp/src/main/decaf/util/logging/Handler.h +++ b/activemq-cpp/src/main/decaf/util/logging/Handler.h @@ -19,7 +19,6 @@ #include #include -#include #include #include diff --git a/activemq-cpp/src/main/decaf/util/logging/Level.cpp b/activemq-cpp/src/main/decaf/util/logging/Level.cpp index 0e389ed77..a5d71ad11 100644 --- a/activemq-cpp/src/main/decaf/util/logging/Level.cpp +++ b/activemq-cpp/src/main/decaf/util/logging/Level.cpp @@ -15,17 +15,19 @@ * limitations under the License. */ +#include + #include "Level.h" #include -#include #include +#include +#include #include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::logging; @@ -97,7 +99,7 @@ Level Level::parse(const std::string& name) nameAsInt = Integer::parseInt(name); isNameAnInt = true; } - catch (NumberFormatException& e) + catch (std::invalid_argument&) { nameAsInt = 0; isNameAnInt = false; @@ -129,11 +131,9 @@ Level Level::parse(const std::string& name) if (!isNameAnInt) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Could not find match for Level Name: %s", - name.c_str()); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": Could not find match for Level Name: " + name); } return Level(name, nameAsInt); diff --git a/activemq-cpp/src/main/decaf/util/logging/Level.h b/activemq-cpp/src/main/decaf/util/logging/Level.h index 6ce58cab7..f0990e101 100644 --- a/activemq-cpp/src/main/decaf/util/logging/Level.h +++ b/activemq-cpp/src/main/decaf/util/logging/Level.h @@ -21,7 +21,7 @@ #include #include -#include +#include namespace decaf { @@ -235,7 +235,7 @@ namespace util * result in a new Level that has been initialized with that int * value and name as the string form of the int. * - * @throws IllegalArgumentException if the value is not valid, + * @throws std::invalid_argument if the value is not valid, * validity means that the string is either a valid int (between * Integer::MIN_VALUE and Integer::MAX_VALUE or is one of the known * level names. diff --git a/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp b/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp index 0f9b7e08d..9bb9717c6 100644 --- a/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp +++ b/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp @@ -16,8 +16,9 @@ */ #include "LogManager.h" +#include #include -#include +#include #include #include #include @@ -31,7 +32,6 @@ using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::logging; @@ -135,9 +135,10 @@ LogManager& LogManager::getLogManager() { if (theManager == NULL) { - throw RuntimeException(__FILE__, - __LINE__, - "The Logging Subsystem is not initialized."); + throw activemq::exceptions::RuntimeException( + __FILE__, + __LINE__, + "The Logging Subsystem is not initialized."); } return *theManager; diff --git a/activemq-cpp/src/main/decaf/util/logging/LogManager.h b/activemq-cpp/src/main/decaf/util/logging/LogManager.h index 76d3a8592..70b12385b 100644 --- a/activemq-cpp/src/main/decaf/util/logging/LogManager.h +++ b/activemq-cpp/src/main/decaf/util/logging/LogManager.h @@ -28,8 +28,7 @@ #include #include -#include -#include +#include namespace decaf { @@ -176,8 +175,8 @@ namespace util * @param logger * The new Logger instance to add to this LogManager. * - * @throws NullPointerException if logger is NULL. - * @throws IllegalArgumentException if the logger has no name. + * @throws std::logic_error if logger is NULL. + * @throws std::invalid_argument if the logger has no name. */ bool addLogger(Logger* logger); @@ -277,7 +276,7 @@ namespace util * @param stream * The InputStream to read the Properties from. * - * @throws NullPointerException if stream is NULL. + * @throws std::logic_error if stream is NULL. * @throws IOException if an I/O error occurs. */ void readConfiguration(decaf::io::InputStream* stream); diff --git a/activemq-cpp/src/main/decaf/util/logging/Logger.cpp b/activemq-cpp/src/main/decaf/util/logging/Logger.cpp index d077a6915..da18dccb7 100644 --- a/activemq-cpp/src/main/decaf/util/logging/Logger.cpp +++ b/activemq-cpp/src/main/decaf/util/logging/Logger.cpp @@ -16,14 +16,16 @@ */ #include "Logger.h" +#include #include #include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::logging; @@ -53,9 +55,10 @@ void Logger::addHandler(Handler* handler) { if (handler == NULL) { - NullPointerException(__FILE__, - __LINE__, - "Logger::addHandler - Handler cannot be null"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Logger::addHandler - Handler cannot be null"); } if (find(handlers.begin(), handlers.end(), handler) != handlers.end()) diff --git a/activemq-cpp/src/main/decaf/util/logging/Logger.h b/activemq-cpp/src/main/decaf/util/logging/Logger.h index 7cdca7dff..979bc930f 100644 --- a/activemq-cpp/src/main/decaf/util/logging/Logger.h +++ b/activemq-cpp/src/main/decaf/util/logging/Logger.h @@ -24,9 +24,6 @@ #include #include -#include -#include - #include #include #include @@ -187,7 +184,7 @@ namespace util * * @param handler A Logging Handler * - * @throws NullPointerException if the Handler given is NULL. + * @throws std::logic_error if the Handler given is NULL. */ void addHandler(Handler* handler); diff --git a/activemq-cpp/src/main/decaf/util/logging/StreamHandler.cpp b/activemq-cpp/src/main/decaf/util/logging/StreamHandler.cpp index 6dd852691..4fccd17bf 100644 --- a/activemq-cpp/src/main/decaf/util/logging/StreamHandler.cpp +++ b/activemq-cpp/src/main/decaf/util/logging/StreamHandler.cpp @@ -17,6 +17,7 @@ #include "StreamHandler.h" +#include #include #include #include @@ -24,10 +25,11 @@ #include #include #include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::util; using namespace decaf::util::logging; @@ -50,16 +52,18 @@ StreamHandler::StreamHandler(OutputStream* stream, Formatter* formatter) { if (stream == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "OutputStream cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "OutputStream cannot be NULL."); } if (formatter == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Formatter cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Formatter cannot be NULL."); } setFormatter(formatter); @@ -158,9 +162,10 @@ void StreamHandler::setOuputStream(decaf::io::OutputStream* stream) { if (stream == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "OutputStream cannot be set to NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "OutputStream cannot be set to NULL."); } this->close(true); diff --git a/activemq-cpp/src/main/decaf/util/logging/StreamHandler.h b/activemq-cpp/src/main/decaf/util/logging/StreamHandler.h index f7624d70b..1cd1b3c0f 100644 --- a/activemq-cpp/src/main/decaf/util/logging/StreamHandler.h +++ b/activemq-cpp/src/main/decaf/util/logging/StreamHandler.h @@ -17,8 +17,6 @@ #ifndef _DECAF_UTIL_LOGGING_STREAMHANDLER_H_ #define _DECAF_UTIL_LOGGING_STREAMHANDLER_H_ -#include -#include #include #include #include @@ -137,7 +135,7 @@ namespace util * @param stream * The new output stream. May not be NULL. * - * @throws NullPointerException if the passed stream is NULL. + * @throws std::logic_error if the passed stream is NULL. */ virtual void setOuputStream(decaf::io::OutputStream* stream); diff --git a/activemq-cpp/src/main/decaf/util/zip/Adler32.cpp b/activemq-cpp/src/main/decaf/util/zip/Adler32.cpp index 89b4c6324..a0609bae4 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Adler32.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/Adler32.cpp @@ -17,11 +17,13 @@ #include "Adler32.h" +#include +#include +#include + #include using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -78,33 +80,31 @@ void Adler32::update(const unsigned char* buffer, { if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + "."); } if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer pointer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer pointer passed was NULL."); } this->value = adler32((uLong)this->value, diff --git a/activemq-cpp/src/main/decaf/util/zip/Adler32.h b/activemq-cpp/src/main/decaf/util/zip/Adler32.h index ad2c7340c..aed73d71d 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Adler32.h +++ b/activemq-cpp/src/main/decaf/util/zip/Adler32.h @@ -73,7 +73,7 @@ namespace util * @param length * The amount of data to read from the byte buffer. * - * @throw IndexOutOfBoundsException if offset + length > size of the + * @throw std::out_of_range if offset + length > size of the * buffer. */ virtual void update(const std::vector& buffer, diff --git a/activemq-cpp/src/main/decaf/util/zip/CRC32.cpp b/activemq-cpp/src/main/decaf/util/zip/CRC32.cpp index 31f6ce531..1cd4db863 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CRC32.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/CRC32.cpp @@ -17,11 +17,13 @@ #include "CRC32.h" +#include +#include +#include + #include using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -63,9 +65,8 @@ void CRC32::update(const std::vector& buffer, { if (offset + length > (int)buffer.size()) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Given offset + length exceeds the length of the buffer."); } @@ -83,9 +84,8 @@ void CRC32::update(const unsigned char* buffer, int size, int offset, int length { if (offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Given offset + length exceeds the length of the buffer."); } diff --git a/activemq-cpp/src/main/decaf/util/zip/CRC32.h b/activemq-cpp/src/main/decaf/util/zip/CRC32.h index 79dd69041..29180d1a9 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CRC32.h +++ b/activemq-cpp/src/main/decaf/util/zip/CRC32.h @@ -72,7 +72,7 @@ namespace util * @param length * The amount of data to read from the byte buffer. * - * @throw IndexOutOfBoundsException if offset + length > size of the + * @throw std::out_of_range if offset + length > size of the * buffer. */ virtual void update(const std::vector& buffer, @@ -91,8 +91,7 @@ namespace util * @param length * The amount of data to read from the byte buffer. * - * @throw NullPointerException if the passed buffer is NULL. - * @throw IndexOutOfBoundsException if offset + length > size of the + * @throw std::out_of_range if offset + length > size of the * buffer. */ virtual void update(const unsigned char* buffer, diff --git a/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.cpp b/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.cpp index 7146f8f8a..833b06064 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.cpp @@ -19,10 +19,13 @@ #include +#include +#include +#include + using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -35,9 +38,10 @@ CheckedInputStream::CheckedInputStream(InputStream* inputStream, { if (sum == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The Checksum instance cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The Checksum instance cannot be NULL."); } } @@ -128,35 +132,33 @@ int CheckedInputStream::doReadArrayBounded(unsigned char* buffer, { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed was NULL"); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed was NULL"); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } if (length == 0) @@ -180,7 +182,5 @@ int CheckedInputStream::doReadArrayBounded(unsigned char* buffer, return result; } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.h b/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.h index 0e91621af..1fd07af36 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.h +++ b/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.h @@ -60,7 +60,8 @@ namespace util * Indicates if this filer should take ownership of the * InputStream. * - * @throws NullPointerException if the Checksum pointer is NULL. + * @throws activemq::exceptions::IllegalStateException if + * the Checksum pointer is NULL. */ CheckedInputStream(InputStream* inputStream, Checksum* sum, diff --git a/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.cpp b/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.cpp index cf0f2176e..f3e60b20e 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.cpp @@ -17,10 +17,13 @@ #include "CheckedOutputStream.h" +#include +#include +#include + using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -33,9 +36,10 @@ CheckedOutputStream::CheckedOutputStream(OutputStream* outputStream, { if (sum == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The Checksum instance cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The Checksum instance cannot be NULL."); } } @@ -71,35 +75,33 @@ void CheckedOutputStream::doWriteArrayBounded(const unsigned char* buffer, { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "The buffer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "The buffer passed was NULL."); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } if (isClosed()) @@ -111,7 +113,5 @@ void CheckedOutputStream::doWriteArrayBounded(const unsigned char* buffer, this->sum->update(buffer, size, offset, length); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.h b/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.h index 773cb1037..16dafc318 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.h +++ b/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.h @@ -61,7 +61,8 @@ namespace util * Indicates if this filer should take ownership of the * InputStream. * - * @throws NullPointerException if the Checksum pointer is NULL. + * @throws activemq::exceptions::IllegalStateException if + * the Checksum pointer is NULL. */ CheckedOutputStream(decaf::io::OutputStream* outputStream, Checksum* sum, diff --git a/activemq-cpp/src/main/decaf/util/zip/Checksum.h b/activemq-cpp/src/main/decaf/util/zip/Checksum.h index b5aade24e..552e49c8f 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Checksum.h +++ b/activemq-cpp/src/main/decaf/util/zip/Checksum.h @@ -20,9 +20,6 @@ #include -#include -#include - #include namespace decaf @@ -70,7 +67,7 @@ namespace util * @param length * The amount of data to read from the byte buffer. * - * @throw IndexOutOfBoundsException if offset + length > size of the + * @throw std::out_of_range if offset + length > size of the * buffer. */ virtual void update(const std::vector& buffer, @@ -89,8 +86,7 @@ namespace util * @param length * The amount of data to read from the byte buffer. * - * @throw NullPointerException if the passed buffer is NULL. - * @throw IndexOutOfBoundsException if offset + length > size of the + * @throw std::out_of_range if offset + length > size of the * buffer. */ virtual void update(const unsigned char* buffer, diff --git a/activemq-cpp/src/main/decaf/util/zip/Deflater.cpp b/activemq-cpp/src/main/decaf/util/zip/Deflater.cpp index 1ba10655b..a31af44e1 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Deflater.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/Deflater.cpp @@ -20,12 +20,15 @@ #include #include -#include +#include #include +#include +#include +#include + using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -72,9 +75,7 @@ namespace util { if (handle == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Error While initializing the Compression Library."); } @@ -112,7 +113,7 @@ namespace util if (result != Z_OK) { - throw RuntimeException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Error While initializing the Compression Library."); @@ -123,9 +124,7 @@ namespace util { if (handle == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Error While initializing the Compression Library."); } @@ -144,9 +143,7 @@ namespace util { if (handle == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Error While initializing the Compression Library."); } @@ -188,11 +185,9 @@ Deflater::Deflater(int level, bool nowrap) { if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) { - throw IllegalArgumentException( - __FILE__, - __LINE__, - "Compression level passed was Invalid: %d", - level); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Compression level passed was Invalid: " + std::to_string(level)); } // Initialize all the ZLib structures. @@ -229,23 +224,24 @@ void Deflater::setInput(const unsigned char* buffer, { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed cannot be NULL."); } if (this->data->stream == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Deflator has already been ended."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Deflator has already been ended."); } if (offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Given offset + length greater than the size of the buffer."); } @@ -261,10 +257,28 @@ void Deflater::setInput(const unsigned char* buffer, this->data->stream->avail_in = (uInt)length; this->data->stream->next_in = (Bytef*)(buffer + offset); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IllegalStateException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IllegalStateException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -296,23 +310,24 @@ void Deflater::setDictionary(const unsigned char* buffer, { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed cannot be NULL."); } if (this->data->stream == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Deflator has already been ended."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Deflator has already been ended."); } if (offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Given offset + length greater than the size of the buffer."); } @@ -326,16 +341,34 @@ void Deflater::setDictionary(const unsigned char* buffer, buffer + offset, (uInt)length) != Z_OK) { - throw IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, "Deflator could not accept the dictionary."); } } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IllegalStateException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IllegalStateException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -362,17 +395,17 @@ void Deflater::setStrategy(int strategy) { if (strategy < DEFAULT_STRATEGY || strategy > HUFFMAN_ONLY) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Strategy value {%d} is not valid.", - strategy); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Strategy value {" + std::to_string(strategy) + "} is not valid."); } if (this->data->stream == NULL && !this->data->ended) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Deflator is in an invalid state."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Deflator is in an invalid state."); } this->data->strategy = strategy; @@ -383,17 +416,17 @@ void Deflater::setLevel(int level) { if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Strategy value {%d} is not valid.", - level); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Compression level passed was Invalid: " + std::to_string(level)); } if (this->data->stream == NULL && !this->data->ended) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Deflator is in an invalid state."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Deflator is in an invalid state."); } this->data->level = level; @@ -429,42 +462,41 @@ int Deflater::deflate(unsigned char* buffer, int size, int offset, int length) { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed cannot be NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed cannot be NULL."); } if (this->data->stream == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Deflator has already been ended."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Deflator has already been ended."); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } unsigned long outStart = this->data->stream->total_out; @@ -483,10 +515,28 @@ int Deflater::deflate(unsigned char* buffer, int size, int offset, int length) return (int)(this->data->stream->total_out - outStart); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IllegalStateException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCHALL_THROW(IllegalStateException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -508,9 +558,10 @@ long long Deflater::getAdler() const { if (this->data->stream == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Deflator has already been ended."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Deflator has already been ended."); } return this->data->stream->adler; @@ -521,9 +572,10 @@ long long Deflater::getBytesRead() const { if (this->data->stream == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Deflator has already been ended."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Deflator has already been ended."); } return this->data->stream->total_in; @@ -534,9 +586,10 @@ long long Deflater::getBytesWritten() const { if (this->data->stream == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Deflator has already been ended."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Deflator has already been ended."); } return this->data->stream->total_out; @@ -547,9 +600,10 @@ void Deflater::reset() { if (this->data->stream == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Deflator has already been ended."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Deflator has already been ended."); } DeflaterData::resetZlibStream(this->data); diff --git a/activemq-cpp/src/main/decaf/util/zip/Deflater.h b/activemq-cpp/src/main/decaf/util/zip/Deflater.h index 7213622ab..04e0c6064 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Deflater.h +++ b/activemq-cpp/src/main/decaf/util/zip/Deflater.h @@ -20,11 +20,7 @@ #include -#include -#include -#include -#include - +#include #include namespace decaf @@ -143,10 +139,12 @@ namespace util * @param length * The number of bytes to read from the input buffer. * - * @throws NullPointerException if buffer is NULL. - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws activemq::exceptions::IllegalStateException if + * buffer is NULL. + * @throws std::out_of_range if the offset + length > size * of the buffer. - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void setInput(const unsigned char* buffer, int size, @@ -165,9 +163,10 @@ namespace util * @param length * The number of bytes to read from the input buffer. * - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws std::out_of_range if the offset + length > size * of the buffer. - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void setInput(const std::vector& buffer, int offset, @@ -181,7 +180,8 @@ namespace util * @param buffer * The Buffer to read in for compression. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void setInput(const std::vector& buffer); @@ -201,10 +201,12 @@ namespace util * @param length * The number of bytes to read from the input buffer. * - * @throws NullPointerException if buffer is NULL. - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws activemq::exceptions::IllegalStateException if + * buffer is NULL. + * @throws std::out_of_range if the offset + length > size * of the buffer. - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void setDictionary(const unsigned char* buffer, int size, @@ -225,9 +227,10 @@ namespace util * @param length * The number of bytes to read from the input buffer. * - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws std::out_of_range if the offset + length > size * of the buffer. - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void setDictionary(const std::vector& buffer, int offset, @@ -243,7 +246,8 @@ namespace util * @param buffer * The buffer containing the preset dictionary. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void setDictionary(const std::vector& buffer); @@ -253,9 +257,10 @@ namespace util * @param strategy * The new Compression strategy to use. * - * @throws IllegalArgumentException if the strategy value is + * @throws std::invalid_argument if the strategy value is * invalid. - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void setStrategy(int strategy); @@ -265,8 +270,9 @@ namespace util * @param level * The new Compression level to use. * - * @throws IllegalArgumentException if the level value is invalid. - * @throws IllegalStateException if in the end state. + * @throws std::invalid_argument if the level value is invalid. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void setLevel(int level); @@ -305,10 +311,12 @@ namespace util * * @return the actual number of bytes of compressed data. * - * @throws NullPointerException if buffer is NULL. - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws activemq::exceptions::IllegalStateException if + * buffer is NULL. + * @throws std::out_of_range if the offset + length > size * of the buffer. - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ int deflate(unsigned char* buffer, int size, int offset, int length); @@ -327,9 +335,10 @@ namespace util * * @return the actual number of bytes of compressed data. * - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws std::out_of_range if the offset + length > size * of the buffer. - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ int deflate(std::vector& buffer, int offset, @@ -346,28 +355,32 @@ namespace util * * @return the actual number of bytes of compressed data. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ int deflate(std::vector& buffer); /** * @return the ADLER-32 value of the uncompressed data. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ long long getAdler() const; /** * @return the total number of uncompressed bytes input so far. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ long long getBytesRead() const; /** * @return the total number of compressed bytes output so far. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ long long getBytesWritten() const; @@ -375,7 +388,8 @@ namespace util * Resets deflater so that a new set of input data can be processed. * Keeps current compression level and strategy settings. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void reset(); diff --git a/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp b/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp index cad091e55..f9f0996d8 100644 --- a/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp @@ -17,10 +17,13 @@ #include "DeflaterOutputStream.h" +#include +#include +#include + using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -51,9 +54,10 @@ DeflaterOutputStream::DeflaterOutputStream(OutputStream* outputStream, { if (deflater == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Deflater passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Deflater passed was NULL."); } this->buf.resize(DEFAULT_BUFFER_SIZE); @@ -73,16 +77,17 @@ DeflaterOutputStream::DeflaterOutputStream(OutputStream* outputStream, { if (deflater == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Deflater passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Deflater passed was NULL."); } if (bufferSize == 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Cannot create a zero sized buffer."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Cannot create a zero sized buffer."); } this->buf.resize(bufferSize); @@ -181,35 +186,33 @@ void DeflaterOutputStream::doWriteArrayBounded(const unsigned char* buffer, if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed was NULL."); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } if (length == 0) @@ -236,8 +239,6 @@ void DeflaterOutputStream::doWriteArrayBounded(const unsigned char* buffer, this->deflate(); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h b/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h index beed492bb..b8274fd2c 100644 --- a/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h +++ b/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h @@ -24,6 +24,7 @@ #include #include +#include #include namespace decaf @@ -95,7 +96,8 @@ namespace util * Should the filter take ownership of the passed Deflater * object (default is false). * - * @throws NullPointerException if the Deflater given is NULL. + * @throws activemq::exceptions::IllegalStateException if + * the Deflater given is NULL. */ DeflaterOutputStream(decaf::io::OutputStream* outputStream, Deflater* deflater, @@ -123,8 +125,9 @@ namespace util * Should the filter take ownership of the passed Deflater * object (default is false). * - * @throws NullPointerException if the Deflater given is NULL. - * @throws IllegalArgumentException if bufferSize is 0. + * @throws activemq::exceptions::IllegalStateException if + * the Deflater given is NULL. + * @throws std::invalid_argument if bufferSize is 0. */ DeflaterOutputStream(decaf::io::OutputStream* outputStream, Deflater* deflater, diff --git a/activemq-cpp/src/main/decaf/util/zip/Inflater.cpp b/activemq-cpp/src/main/decaf/util/zip/Inflater.cpp index 1b5f34b42..9ee1f6373 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Inflater.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/Inflater.cpp @@ -22,11 +22,14 @@ #include -#include +#include + +#include +#include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -68,9 +71,7 @@ namespace util { if (handle == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Error While initializing the Decompression Library."); } @@ -100,7 +101,7 @@ namespace util if (result != Z_OK) { - throw RuntimeException( + throw activemq::exceptions::NullPointerException( __FILE__, __LINE__, "Error While initializing the Decompression Library."); @@ -111,9 +112,7 @@ namespace util { if (handle == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Error While initializing the Decompression Library."); } @@ -130,9 +129,7 @@ namespace util { if (handle == NULL) { - throw NullPointerException( - __FILE__, - __LINE__, + throw activemq::exceptions::NullPointerException( "Error While initializing the Decompression Library."); } @@ -193,24 +190,25 @@ void Inflater::setInput(const unsigned char* buffer, { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Passed Buffer was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Passed Buffer was NULL."); } if (this->data->stream == NULL) { - throw IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "The Inflater end method has already been called."); + "The Inflater end method has already been " + "called."); } if (offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "The offset + length given is greater than the specified " "buffer size."); } @@ -218,10 +216,28 @@ void Inflater::setInput(const unsigned char* buffer, this->data->stream->avail_in = (uInt)length; this->data->stream->next_in = (Bytef*)(buffer + offset); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(IllegalStateException) - DECAF_CATCHALL_THROW(IllegalStateException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -269,24 +285,25 @@ void Inflater::setDictionary(const unsigned char* buffer, { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Passed Buffer was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Passed Buffer was NULL."); } if (this->data->stream == NULL) { - throw IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "The Inflater end method has already been called."); + "The Inflater end method has already been " + "called."); } if (offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "The offset + length given is greater than the specified " "buffer size."); } @@ -303,17 +320,33 @@ void Inflater::setDictionary(const unsigned char* buffer, (uInt)length); if (result != Z_OK) { - throw IllegalArgumentException( - __FILE__, - __LINE__, + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Dictionary given does not match required checksum value."); } } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(IllegalStateException) - DECAF_CATCH_RETHROW(IllegalArgumentException) - DECAF_CATCHALL_THROW(IllegalStateException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } + catch (...) + { + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -376,43 +409,42 @@ int Inflater::inflate(unsigned char* buffer, int size, int offset, int length) { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Passed Buffer was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Passed Buffer was NULL."); } if (this->data->stream == NULL) { - throw IllegalStateException( + throw activemq::exceptions::IllegalStateException( __FILE__, __LINE__, - "The Inflater end method has already been called."); + "The Inflater end method has already been " + "called."); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } unsigned long outStart = this->data->stream->total_out; @@ -450,11 +482,29 @@ int Inflater::inflate(unsigned char* buffer, int size, int offset, int length) return (int)(this->data->stream->total_out - outStart); } - DECAF_CATCH_RETHROW(NullPointerException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + catch (::activemq::exceptions::OutOfRangeException&) + { + throw; + } + catch (std::invalid_argument&) + { + throw; + } + catch (activemq::exceptions::NullPointerException&) + { + throw; + } + catch (activemq::exceptions::IllegalStateException&) + { + throw; + } DECAF_CATCH_RETHROW(DataFormatException) - DECAF_CATCH_RETHROW(IllegalStateException) - DECAF_CATCHALL_THROW(IllegalStateException) + catch (...) + { + throw activemq::exceptions::IllegalStateException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + + ": caught unknown exception"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -486,9 +536,10 @@ long long Inflater::getAdler() const { if (this->data->stream == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Inflater has already been ended."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Inflater has already been ended."); } return this->data->stream->adler; @@ -499,9 +550,10 @@ long long Inflater::getBytesRead() const { if (this->data->stream == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Inflater has already been ended."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Inflater has already been ended."); } return this->data->stream->total_in; @@ -512,9 +564,10 @@ long long Inflater::getBytesWritten() const { if (this->data->stream == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Inflater has already been ended."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Inflater has already been ended."); } return this->data->stream->total_out; @@ -525,9 +578,10 @@ void Inflater::reset() { if (this->data->stream == NULL) { - throw IllegalStateException(__FILE__, - __LINE__, - "The Inflater has already been ended."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "The Inflater has already been ended."); } InflaterData::resetZlibStream(this->data); diff --git a/activemq-cpp/src/main/decaf/util/zip/Inflater.h b/activemq-cpp/src/main/decaf/util/zip/Inflater.h index aaa0214d2..403ad1d95 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Inflater.h +++ b/activemq-cpp/src/main/decaf/util/zip/Inflater.h @@ -20,13 +20,9 @@ #include -#include -#include -#include -#include - #include +#include #include namespace decaf @@ -97,10 +93,12 @@ namespace util * @param length * The number of bytes to read from the input buffer. * - * @throws NullPointerException if buffer is NULL. - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws activemq::exceptions::IllegalStateException if + * buffer is NULL. + * @throws std::out_of_range if the offset + length > size * of the buffer. - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void setInput(const unsigned char* buffer, int size, @@ -119,9 +117,10 @@ namespace util * @param length * The number of bytes to read from the input buffer. * - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws std::out_of_range if the offset + length > size * of the buffer. - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void setInput(const std::vector& buffer, int offset, @@ -135,7 +134,8 @@ namespace util * @param buffer * The Buffer to read in for decompression. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void setInput(const std::vector& buffer); @@ -164,11 +164,13 @@ namespace util * @param length * The number of bytes to read from the input buffer. * - * @throws NullPointerException if buffer is NULL. - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws activemq::exceptions::IllegalStateException if + * buffer is NULL. + * @throws std::out_of_range if the offset + length > size * of the buffer. - * @throws IllegalStateException if in the end state. - * @throws IllegalArgumentException if the given dictionary doesn't + * @throws activemq::exceptions::IllegalStateException if in + * the end state. + * @throws std::invalid_argument if the given dictionary doesn't * match thre required dictionaries checksum value. */ void setDictionary(const unsigned char* buffer, @@ -190,10 +192,11 @@ namespace util * @param length * The number of bytes to read from the input buffer. * - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws std::out_of_range if the offset + length > size * of the buffer. - * @throws IllegalStateException if in the end state. - * @throws IllegalArgumentException if the given dictionary doesn't + * @throws activemq::exceptions::IllegalStateException if in + * the end state. + * @throws std::invalid_argument if the given dictionary doesn't * match thre required dictionaries checksum value. */ void setDictionary(const std::vector& buffer, @@ -210,8 +213,9 @@ namespace util * @param buffer * The Buffer to read in for decompression. * - * @throws IllegalStateException if in the end state. - * @throws IllegalArgumentException if the given dictionary doesn't + * @throws activemq::exceptions::IllegalStateException if in + * the end state. + * @throws std::invalid_argument if the given dictionary doesn't * match the required dictionaries checksum value. */ void setDictionary(const std::vector& buffer); @@ -256,9 +260,11 @@ namespace util * @param length * The maximum number of byte of data to write. * - * @throws NullPointerException if buffer is NULL. - * @throws IllegalStateException if in the end state. - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws activemq::exceptions::IllegalStateException if + * buffer is NULL. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. + * @throws std::out_of_range if the offset + length > size * of the buffer. * @throws DataFormatException if the compressed data format is * invalid. @@ -280,8 +286,9 @@ namespace util * @param length * The maximum number of byte of data to write. * - * @throws IllegalStateException if in the end state. - * @throws IndexOutOfBoundsException if the offset + length > size + * @throws activemq::exceptions::IllegalStateException if in + * the end state. + * @throws std::out_of_range if the offset + length > size * of the buffer. * @throws DataFormatException if the compressed data format is * invalid. @@ -301,7 +308,8 @@ namespace util * @param buffer * The Buffer to write the compressed data to. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. * @throws DataFormatException if the compressed data format is * invalid. */ @@ -310,21 +318,24 @@ namespace util /** * @return the ADLER-32 value of the uncompressed data. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ long long getAdler() const; /** * @return the total number of compressed bytes input so far. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ long long getBytesRead() const; /** * @return the total number of decompressed bytes output so far. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ long long getBytesWritten() const; @@ -332,7 +343,8 @@ namespace util * Resets deflater so that a new set of input data can be processed. * Keeps current decompression level and strategy settings. * - * @throws IllegalStateException if in the end state. + * @throws activemq::exceptions::IllegalStateException if in + * the end state. */ void reset(); diff --git a/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp b/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp index fa4ea7b6b..4e46cbf38 100644 --- a/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp @@ -20,10 +20,13 @@ #include #include +#include +#include +#include + using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -56,9 +59,10 @@ InflaterInputStream::InflaterInputStream(InputStream* inputStream, { if (inflater == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Inflater passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Inflater passed was NULL."); } this->buff.resize(DEFAULT_BUFFER_SIZE); @@ -79,16 +83,17 @@ InflaterInputStream::InflaterInputStream(InputStream* inputStream, { if (inflater == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Inflater passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Inflater passed was NULL."); } if (bufferSize <= 0) { - throw IllegalArgumentException(__FILE__, - __LINE__, - "Cannot create a zero sized buffer."); + throw activemq::exceptions::InvalidArgumentException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "Cannot create a zero sized buffer."); } this->buff.resize(bufferSize); @@ -227,35 +232,33 @@ int InflaterInputStream::doReadArrayBounded(unsigned char* buffer, { if (buffer == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "Buffer passed was NULL."); + throw activemq::exceptions::NullPointerException( + __FILE__, + __LINE__, + "Buffer passed was NULL."); } if (size < 0) { - throw IndexOutOfBoundsException(__FILE__, - __LINE__, - "size parameter out of Bounds: %d.", - size); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "size parameter out of Bounds: " + std::to_string(size) + "."); } if (offset > size || offset < 0) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset parameter out of Bounds: %d.", - offset); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "offset parameter out of Bounds: " + std::to_string(offset) + + "."); } if (length < 0 || length > size - offset) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "length parameter out of Bounds: %d.", - length); + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "length parameter out of Bounds: " + std::to_string(length) + + "."); } if (length == 0) @@ -327,8 +330,6 @@ int InflaterInputStream::doReadArrayBounded(unsigned char* buffer, } while (true); } DECAF_CATCH_RETHROW(IOException) - DECAF_CATCH_RETHROW(IndexOutOfBoundsException) - DECAF_CATCH_RETHROW(NullPointerException) DECAF_CATCHALL_THROW(IOException) } diff --git a/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h b/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h index 26004b57d..5491cae5d 100644 --- a/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h +++ b/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h @@ -24,6 +24,7 @@ #include #include +#include #include namespace decaf @@ -101,7 +102,8 @@ namespace util * Should the filter take ownership of the passed Inflater * object (default is false). * - * @throws NullPointerException if the Inflater given is NULL. + * @throws activemq::exceptions::IllegalStateException if + * the Inflater given is NULL. */ InflaterInputStream(decaf::io::InputStream* inputStream, Inflater* inflater, @@ -129,8 +131,9 @@ namespace util * Should the filter take ownership of the passed Inflater * object (default is false). * - * @throws NullPointerException if the Inflater given is NULL. - * @throws IllegalArgumentException if the bufferSize value is zero. + * @throws activemq::exceptions::IllegalStateException if + * the Inflater given is NULL. + * @throws std::invalid_argument if the bufferSize value is zero. */ InflaterInputStream(decaf::io::InputStream* inputStream, Inflater* inflater, diff --git a/activemq-cpp/src/test-integration/activemq/test/AdvisoryTest.cpp b/activemq-cpp/src/test-integration/activemq/test/AdvisoryTest.cpp index 19155468d..b4004cdab 100644 --- a/activemq-cpp/src/test-integration/activemq/test/AdvisoryTest.cpp +++ b/activemq-cpp/src/test-integration/activemq/test/AdvisoryTest.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -53,7 +52,6 @@ using namespace cms; using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace activemq; diff --git a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireMessageListenerRedeliveryTest.cpp b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireMessageListenerRedeliveryTest.cpp index 66dad6c5b..cb5c3a994 100644 --- a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireMessageListenerRedeliveryTest.cpp +++ b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireMessageListenerRedeliveryTest.cpp @@ -66,7 +66,6 @@ using namespace cms; using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::atomic; @@ -186,7 +185,7 @@ class ExceptionMessageListener : public cms::MessageListener if (++count < maxDeliveries) { - throw decaf::lang::exceptions::RuntimeException( + throw decaf::lang::Exception( __FILE__, __LINE__, testName.append(" forced a redelivery").c_str()); @@ -290,7 +289,7 @@ class FailingMessageListener : public cms::MessageListener e.printStackTrace(); } - throw decaf::lang::exceptions::RuntimeException( + throw decaf::lang::Exception( __FILE__, __LINE__, (testName + " forced a redelivery").c_str()); diff --git a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisoryTest.cpp b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisoryTest.cpp index b65013bfd..4293e9dba 100644 --- a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisoryTest.cpp +++ b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisoryTest.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -148,7 +147,6 @@ using namespace cms; using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace activemq; @@ -194,19 +192,13 @@ TEST_F(OpenwireAdvisoryTest, testConnectionAdvisories) dynamic_cast(message.get()); if (amqMessage != NULL) { - try - { - std::shared_ptr connectionInfo = - std::dynamic_pointer_cast( - amqMessage->getDataStructure()); + std::shared_ptr connectionInfo = + std::dynamic_pointer_cast( + amqMessage->getDataStructure()); - if (connectionInfo != NULL) - { - connectionInfoCount++; - } - } - catch (ClassCastException& ex) + if (connectionInfo != NULL) { + connectionInfoCount++; } } diff --git a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireEnhancedConnectionTest.cpp b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireEnhancedConnectionTest.cpp index 4d118967e..886e09c4c 100644 --- a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireEnhancedConnectionTest.cpp +++ b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireEnhancedConnectionTest.cpp @@ -40,7 +40,6 @@ using namespace cms; using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace activemq; diff --git a/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslAdvisoryTest.cpp b/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslAdvisoryTest.cpp index b35d811a0..92aef66c0 100644 --- a/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslAdvisoryTest.cpp +++ b/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslAdvisoryTest.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -148,7 +147,6 @@ using namespace cms; using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace activemq; @@ -194,19 +192,13 @@ TEST_F(OpenwireSslAdvisoryTest, testConnectionAdvisories) dynamic_cast(message.get()); if (amqMessage != NULL) { - try - { - std::shared_ptr connectionInfo = - std::dynamic_pointer_cast( - amqMessage->getDataStructure()); + std::shared_ptr connectionInfo = + std::dynamic_pointer_cast( + amqMessage->getDataStructure()); - if (connectionInfo != NULL) - { - connectionInfoCount++; - } - } - catch (ClassCastException& ex) + if (connectionInfo != NULL) { + connectionInfoCount++; } } diff --git a/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslEnhancedConnectionTest.cpp b/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslEnhancedConnectionTest.cpp index 99a4a98b6..a606813b2 100644 --- a/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslEnhancedConnectionTest.cpp +++ b/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslEnhancedConnectionTest.cpp @@ -40,7 +40,6 @@ using namespace cms; using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace activemq; diff --git a/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslMessageListenerRedeliveryTest.cpp b/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslMessageListenerRedeliveryTest.cpp index bddca2e97..29087efec 100644 --- a/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslMessageListenerRedeliveryTest.cpp +++ b/activemq-cpp/src/test-integration/activemq/test/openwire_ssl/OpenwireSslMessageListenerRedeliveryTest.cpp @@ -66,7 +66,6 @@ using namespace cms; using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::atomic; @@ -186,7 +185,7 @@ class ExceptionMessageListener : public cms::MessageListener if (++count < maxDeliveries) { - throw decaf::lang::exceptions::RuntimeException( + throw decaf::lang::Exception( __FILE__, __LINE__, testName.append(" forced a redelivery").c_str()); @@ -290,7 +289,7 @@ class FailingMessageListener : public cms::MessageListener e.printStackTrace(); } - throw decaf::lang::exceptions::RuntimeException( + throw decaf::lang::Exception( __FILE__, __LINE__, (testName + " forced a redelivery").c_str()); diff --git a/activemq-cpp/src/test-integration/activemq/test/stomp/StompAdvisoryTest.cpp b/activemq-cpp/src/test-integration/activemq/test/stomp/StompAdvisoryTest.cpp index 114008b25..aa4c2f91d 100644 --- a/activemq-cpp/src/test-integration/activemq/test/stomp/StompAdvisoryTest.cpp +++ b/activemq-cpp/src/test-integration/activemq/test/stomp/StompAdvisoryTest.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -68,7 +67,6 @@ using namespace cms; using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace activemq; diff --git a/activemq-cpp/src/test-integration/activemq/util/CMSProvider.cpp b/activemq-cpp/src/test-integration/activemq/util/CMSProvider.cpp index c5baa2872..7f42d5da1 100644 --- a/activemq-cpp/src/test-integration/activemq/util/CMSProvider.cpp +++ b/activemq-cpp/src/test-integration/activemq/util/CMSProvider.cpp @@ -24,8 +24,9 @@ #include #include -#include #include +#include +#include using namespace std; using namespace cms; @@ -35,7 +36,6 @@ using namespace activemq::core; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// CMSProvider::CMSProvider(const std::string& brokerURL, @@ -255,9 +255,8 @@ void CMSProvider::reconnectSession() { if (this->connection.get() == NULL) { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, + throw std::logic_error( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CMSProvider has not been Initialized or is closed."); } @@ -296,9 +295,8 @@ void CMSProvider::unsubscribe() { if (this->connection.get() == NULL) { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, + throw std::logic_error( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CMSProvider has not been Initialized or is closed."); } @@ -323,9 +321,8 @@ cms::ConnectionFactory* CMSProvider::getConnectionFactory() { if (this->connectionFactory.get() == NULL) { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, + throw std::logic_error( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CMSProvider has not been Initialized or is closed."); } @@ -342,9 +339,8 @@ cms::Connection* CMSProvider::getConnection() { if (this->connection.get() == NULL) { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, + throw std::logic_error( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CMSProvider has not been Initialized or is closed."); } @@ -361,9 +357,8 @@ cms::Session* CMSProvider::getSession() { if (this->connection.get() == NULL) { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, + throw std::logic_error( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CMSProvider has not been Initialized or is closed."); } @@ -380,9 +375,8 @@ cms::MessageProducer* CMSProvider::getProducer() { if (this->connection.get() == NULL) { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, + throw std::logic_error( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CMSProvider has not been Initialized or is closed."); } @@ -405,9 +399,8 @@ cms::MessageProducer* CMSProvider::getNoDestProducer() { if (this->connection.get() == NULL) { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, + throw std::logic_error( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CMSProvider has not been Initialized or is closed."); } @@ -430,9 +423,8 @@ cms::MessageConsumer* CMSProvider::getConsumer() { if (this->connection.get() == NULL) { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, + throw std::logic_error( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CMSProvider has not been Initialized or is closed."); } @@ -465,9 +457,8 @@ cms::Destination* CMSProvider::getDestination() { if (this->connection.get() == NULL) { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, + throw std::logic_error( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CMSProvider has not been Initialized or is closed."); } @@ -498,9 +489,8 @@ cms::Destination* CMSProvider::getTempDestination() { if (this->connection.get() == NULL) { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, + throw std::logic_error( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CMSProvider has not been Initialized or is closed."); } @@ -531,9 +521,8 @@ void CMSProvider::destroyDestination(const cms::Destination* destination) { if (this->connection.get() == NULL) { - throw decaf::lang::exceptions::IllegalStateException( - __FILE__, - __LINE__, + throw std::logic_error( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "CMSProvider has not been Initialized or is closed."); } diff --git a/activemq-cpp/src/test/activemq/core/LazyPropertyUnmarshalTest.cpp b/activemq-cpp/src/test/activemq/core/LazyPropertyUnmarshalTest.cpp index 0aee5f6b4..fdb323e27 100644 --- a/activemq-cpp/src/test/activemq/core/LazyPropertyUnmarshalTest.cpp +++ b/activemq-cpp/src/test/activemq/core/LazyPropertyUnmarshalTest.cpp @@ -148,7 +148,7 @@ void LazyPropertyUnmarshalTest::testCorruptedPropertiesThrowIOException() message->getMessageProperties(); FAIL() << ("Expected IOException for corrupted properties"); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { exceptionThrown = true; // Expected - corrupted properties should throw IOException @@ -262,7 +262,7 @@ void LazyPropertyUnmarshalTest::testCorruptedMessageDoesNotCloseConnection() { message->getMessageProperties(); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { ioExceptionThrown = true; } diff --git a/activemq-cpp/src/test/activemq/exceptions/ActiveMQExceptionTest.cpp b/activemq-cpp/src/test/activemq/exceptions/ActiveMQExceptionTest.cpp index 8e6e9996d..4d4f25a7b 100644 --- a/activemq-cpp/src/test/activemq/exceptions/ActiveMQExceptionTest.cpp +++ b/activemq-cpp/src/test/activemq/exceptions/ActiveMQExceptionTest.cpp @@ -18,16 +18,15 @@ #include #include #include -#include -#include +#include #include #include +#include using namespace activemq; using namespace activemq::exceptions; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class ActiveMQExceptionTest : public ::testing::Test { @@ -54,9 +53,7 @@ TEST_F(ActiveMQExceptionTest, testMacros) { try { - throw UnsupportedOperationException(__FILE__, - __LINE__, - "EXCEPTION"); + throw decaf::io::IOException(__FILE__, __LINE__, "EXCEPTION"); FAIL() << ("Should not get this far."); } AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) @@ -67,8 +64,8 @@ TEST_F(ActiveMQExceptionTest, testMacros) { ASSERT_TRUE(ex.getCause() != NULL); - const UnsupportedOperationException* cause = - dynamic_cast(ex.getCause()); + const decaf::io::IOException* cause = + dynamic_cast(ex.getCause()); ASSERT_TRUE(cause != NULL); } @@ -90,9 +87,7 @@ TEST_F(ActiveMQExceptionTest, testMacros) { try { - throw UnsupportedOperationException(__FILE__, - __LINE__, - "EXCEPTION"); + throw decaf::io::IOException(__FILE__, __LINE__, "EXCEPTION"); FAIL() << ("Should not get this far."); } AMQ_CATCH_EXCEPTION_CONVERT(Exception, ActiveMQException) @@ -106,9 +101,8 @@ TEST_F(ActiveMQExceptionTest, testMacros) ASSERT_TRUE(converted != NULL); ASSERT_TRUE(converted->getCause() != NULL); - const UnsupportedOperationException* cause = - dynamic_cast( - converted->getCause()); + const decaf::io::IOException* cause = + dynamic_cast(converted->getCause()); ASSERT_TRUE(cause != NULL); } diff --git a/activemq-cpp/src/test/activemq/mock/MockBrokerService.cpp b/activemq-cpp/src/test/activemq/mock/MockBrokerService.cpp index e51e3717c..8b3debd34 100644 --- a/activemq-cpp/src/test/activemq/mock/MockBrokerService.cpp +++ b/activemq-cpp/src/test/activemq/mock/MockBrokerService.cpp @@ -144,9 +144,10 @@ namespace mock }); if (error && !serverStarted) { - throw IOException(__FILE__, - __LINE__, - "Mock broker failed to start"); + throw activemq::exceptions::IOException( + __FILE__, + __LINE__, + "Mock broker failed to start"); } } @@ -228,7 +229,7 @@ namespace mock server->bind("0.0.0.0", configuredPort); bindSucceeded = true; } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { // Bind failed - could be TIME_WAIT or port in use server.reset(); @@ -338,9 +339,11 @@ namespace mock // Don't set SO_LINGER to avoid RST on close clientSocket->setTcpNoDelay( true); // Disable Nagle's algorithm for immediate sends - // Set socket timeout to allow thread to check done flag - // periodically - clientSocket->setSoTimeout(1000); // 1 second timeout + // Allow slow handshakes on loaded CI; the command loop + // still wakes periodically to observe `done` (keep this + // bounded so broker stop() does not stall tests for too + // long). + clientSocket->setSoTimeout(10000); // 10 second timeout std::shared_ptr preferred = wireFormat->getPreferedWireFormatInfo(); @@ -391,7 +394,7 @@ namespace mock // Timeout allows us to check done flag continue; } - catch (IOException& ioe) + catch (activemq::exceptions::IOException& ioe) { // Socket closed or connection error break; @@ -401,7 +404,7 @@ namespace mock // destroyed here, before the socket is closed } } - catch (IOException& ioe) + catch (activemq::exceptions::IOException& ioe) { // Failed during handshake or stream operations // Clean up and wait for next connection @@ -428,7 +431,7 @@ namespace mock } } } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { error.store(true, std::memory_order_release); } diff --git a/activemq-cpp/src/test/activemq/state/ConnectionStateTrackerTest.cpp b/activemq-cpp/src/test/activemq/state/ConnectionStateTrackerTest.cpp index 05b3046fc..03a65465b 100644 --- a/activemq-cpp/src/test/activemq/state/ConnectionStateTrackerTest.cpp +++ b/activemq-cpp/src/test/activemq/state/ConnectionStateTrackerTest.cpp @@ -21,14 +21,16 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include +#include +#include using namespace std; using namespace activemq; @@ -38,7 +40,6 @@ using namespace activemq::transport; using namespace activemq::wireformat; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class ConnectionStateTrackerTest : public ::testing::Test { @@ -107,20 +108,29 @@ class TrackingTransport : public activemq::transport::Transport const std::shared_ptr command, const std::shared_ptr responseCallback) { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } virtual std::shared_ptr request( const std::shared_ptr command) { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } virtual std::shared_ptr request( const std::shared_ptr command, unsigned int timeout) { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } virtual std::shared_ptr getWireFormat() const diff --git a/activemq-cpp/src/test/activemq/threads/DedicatedTaskRunnerTest.cpp b/activemq-cpp/src/test/activemq/threads/DedicatedTaskRunnerTest.cpp index 20c7d0469..5071e87d4 100644 --- a/activemq-cpp/src/test/activemq/threads/DedicatedTaskRunnerTest.cpp +++ b/activemq-cpp/src/test/activemq/threads/DedicatedTaskRunnerTest.cpp @@ -23,12 +23,11 @@ #include #include -#include +#include using namespace activemq; using namespace activemq::threads; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class DedicatedTaskRunnerTest : public ::testing::Test { @@ -97,8 +96,8 @@ class InfiniteCountingTask : public Task TEST_F(DedicatedTaskRunnerTest, testSimple) { ASSERT_THROW(std::unique_ptr(new DedicatedTaskRunner(NULL)), - NullPointerException) - << ("Should throw a NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); SimpleCountingTask simpleTask; ASSERT_TRUE(simpleTask.getCount() == 0); diff --git a/activemq-cpp/src/test/activemq/threads/SchedulerTest.cpp b/activemq-cpp/src/test/activemq/threads/SchedulerTest.cpp index 22fea3391..89e387082 100644 --- a/activemq-cpp/src/test/activemq/threads/SchedulerTest.cpp +++ b/activemq-cpp/src/test/activemq/threads/SchedulerTest.cpp @@ -20,12 +20,11 @@ #include #include #include -#include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace activemq; using namespace activemq::threads; @@ -92,12 +91,12 @@ TEST_F(SchedulerTest, testScheduleNullRunnableThrows) Scheduler scheduler("testSchedualPeriodically"); scheduler.start(); - ASSERT_THROW(scheduler.schedualPeriodically(NULL, 400), NullPointerException) - << ("Should have thrown a NullPointerException"); - ASSERT_THROW(scheduler.executePeriodically(NULL, 400), NullPointerException) - << ("Should have thrown a NullPointerException"); - ASSERT_THROW(scheduler.executeAfterDelay(NULL, 400), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(scheduler.schedualPeriodically(NULL, 400), std::logic_error) + << ("Should have thrown std::logic_error"); + ASSERT_THROW(scheduler.executePeriodically(NULL, 400), std::logic_error) + << ("Should have thrown std::logic_error"); + ASSERT_THROW(scheduler.executeAfterDelay(NULL, 400), std::logic_error) + << ("Should have thrown std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/activemq/transport/CorruptedMessageTest.cpp b/activemq-cpp/src/test/activemq/transport/CorruptedMessageTest.cpp index e612fa573..ece069ace 100644 --- a/activemq-cpp/src/test/activemq/transport/CorruptedMessageTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/CorruptedMessageTest.cpp @@ -18,6 +18,8 @@ #include #include +#include + #include #include #include @@ -558,7 +560,7 @@ TEST_F(CorruptedMessageTest, testCorruptedFirstMessage) std::shared_ptr cmd = wireFormat->unmarshal(nullptr, dis.get()); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { caughtException = true; // This is expected - corrupted data should throw @@ -567,6 +569,10 @@ TEST_F(CorruptedMessageTest, testCorruptedFirstMessage) { caughtException = true; } + catch (std::exception&) + { + caughtException = true; + } ASSERT_TRUE(caughtException) << ("Corrupted message should throw exception during unmarshal"); @@ -645,6 +651,10 @@ TEST_F(CorruptedMessageTest, testCorruptedMessageBetweenValidMessages) { FAIL() << ("First message should unmarshal successfully"); } + catch (std::exception&) + { + FAIL() << ("First message should unmarshal successfully"); + } // Message 2 - should throw (corrupted) try @@ -653,7 +663,7 @@ TEST_F(CorruptedMessageTest, testCorruptedMessageBetweenValidMessages) wireFormat->unmarshal(nullptr, dis.get()); FAIL() << ("Corrupted message should throw exception"); } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { corruptedCount++; // Expected - corrupted message @@ -663,6 +673,11 @@ TEST_F(CorruptedMessageTest, testCorruptedMessageBetweenValidMessages) corruptedCount++; // Also acceptable } + catch (std::exception&) + { + corruptedCount++; + // Also acceptable + } // Message 3 - NOTE: Stream is now desynchronized due to corruption // This demonstrates why we need MAX_CONSECUTIVE_ERRORS and reconnection @@ -718,6 +733,10 @@ TEST_F(CorruptedMessageTest, testContinueAfterCorruptedMessage) { caughtException = true; } + catch (std::exception&) + { + caughtException = true; + } ASSERT_TRUE(caughtException) << ("Corrupted message should throw exception"); @@ -776,6 +795,10 @@ TEST_F(CorruptedMessageTest, testMultipleCorruptedMessages) { corruptedCount++; } + catch (std::exception&) + { + corruptedCount++; + } } ASSERT_EQ(5, corruptedCount) << ("Should have caught 5 corrupted messages"); @@ -819,6 +842,10 @@ TEST_F(CorruptedMessageTest, testCorruptedMessageWithoutMessageId) { caughtException = true; } + catch (std::exception&) + { + caughtException = true; + } ASSERT_TRUE(caughtException) << ("Early corruption should throw exception"); @@ -876,6 +903,10 @@ TEST_F(CorruptedMessageTest, testMaxConsecutiveErrors) { corruptedCount++; } + catch (std::exception&) + { + corruptedCount++; + } } ASSERT_EQ(MAX_ERRORS, corruptedCount) @@ -951,6 +982,11 @@ TEST_F(CorruptedMessageTest, testPoisonAckSent) FAIL() << (std::string("POISON_ACK marshal should succeed: ") + e.getMessage()); } + catch (std::exception& e) + { + FAIL() << (std::string("POISON_ACK marshal should succeed: ") + + e.what()); + } // Verify we wrote some bytes std::pair ackData = baos->toByteArray(); @@ -1007,6 +1043,10 @@ TEST_F(CorruptedMessageTest, testStreamResyncAfterSingleCorruption) { FAIL() << ("Valid message should unmarshal successfully"); } + catch (std::exception&) + { + FAIL() << ("Valid message should unmarshal successfully"); + } // After corruption, we do NOT attempt resync // Instead, we rely on: @@ -1075,6 +1115,10 @@ TEST_F(CorruptedMessageTest, testCorruptedMessageDuringFailover) { errorCount++; } + catch (std::exception&) + { + errorCount++; + } } ASSERT_EQ(10, errorCount); @@ -1123,6 +1167,10 @@ TEST_F(CorruptedMessageTest, testCorruptionInDifferentMessageParts) { caught = true; } + catch (std::exception&) + { + caught = true; + } ASSERT_TRUE(caught) << ("Early corruption should throw"); } @@ -1145,6 +1193,10 @@ TEST_F(CorruptedMessageTest, testCorruptionInDifferentMessageParts) { caught = true; } + catch (std::exception&) + { + caught = true; + } ASSERT_TRUE(caught) << ("Properties corruption should throw"); } @@ -1168,6 +1220,10 @@ TEST_F(CorruptedMessageTest, testCorruptionInDifferentMessageParts) { caught = true; } + catch (std::exception&) + { + caught = true; + } ASSERT_TRUE(caught) << ("Truncated message should throw"); } @@ -1229,6 +1285,10 @@ TEST_F(CorruptedMessageTest, testCorruptedMessageNonDurableConsumer) { caughtException = true; } + catch (std::exception&) + { + caughtException = true; + } ASSERT_TRUE(caughtException) << ("Non-durable consumer corrupted message should throw exception"); @@ -1293,6 +1353,10 @@ TEST_F(CorruptedMessageTest, testCorruptedMessageDurableTopicSubscriber) { caughtException = true; } + catch (std::exception&) + { + caughtException = true; + } ASSERT_TRUE(caughtException) << ("Durable subscriber corrupted message should throw exception"); @@ -1376,6 +1440,12 @@ TEST_F(CorruptedMessageTest, testPoisonAckForDurableSubscriber) "should succeed: ") + e.getMessage()); } + catch (std::exception& e) + { + FAIL() << (std::string("POISON_ACK marshal for durable subscriber " + "should succeed: ") + + e.what()); + } std::pair ackData = baos->toByteArray(); std::vector ackBytes(ackData.first, @@ -1443,7 +1513,7 @@ TEST_F(CorruptedMessageTest, testEOFDuringMessageIdRead) caughtException = true; exceptionType = "EOFException"; } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { caughtException = true; exceptionType = "IOException"; @@ -1453,6 +1523,11 @@ TEST_F(CorruptedMessageTest, testEOFDuringMessageIdRead) caughtException = true; exceptionType = "Exception"; } + catch (std::exception&) + { + caughtException = true; + exceptionType = "std::exception"; + } ASSERT_TRUE(caughtException) << ("EOF during MessageId read should throw exception"); @@ -1517,7 +1592,7 @@ TEST_F(CorruptedMessageTest, testEOFDuringPropertiesRead) { caughtException = true; } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { caughtException = true; } @@ -1525,6 +1600,10 @@ TEST_F(CorruptedMessageTest, testEOFDuringPropertiesRead) { caughtException = true; } + catch (std::exception&) + { + caughtException = true; + } ASSERT_TRUE(caughtException) << ("EOF during properties read should throw exception"); @@ -1594,7 +1673,7 @@ TEST_F(CorruptedMessageTest, testEOFDuringBodyRead) { caughtException = true; } - catch (IOException& e) + catch (activemq::exceptions::IOException& e) { caughtException = true; } @@ -1602,6 +1681,10 @@ TEST_F(CorruptedMessageTest, testEOFDuringBodyRead) { caughtException = true; } + catch (std::exception&) + { + caughtException = true; + } ASSERT_TRUE(caughtException) << ("EOF during body read should throw exception"); diff --git a/activemq-cpp/src/test/activemq/transport/IOTransportTest.cpp b/activemq-cpp/src/test/activemq/transport/IOTransportTest.cpp index 9639fdcb1..24507fe26 100644 --- a/activemq-cpp/src/test/activemq/transport/IOTransportTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/IOTransportTest.cpp @@ -28,17 +28,19 @@ #include #include #include -#include #include #include #include #include +#include +#include +#include + using namespace activemq; using namespace activemq::transport; using namespace activemq::exceptions; using namespace decaf::io; -using namespace decaf::lang::exceptions; class IOTransportTest : public ::testing::Test { @@ -134,14 +136,15 @@ class MyWireFormat : public wireformat::WireFormat { if (throwException) { - throw IOException(); + throw activemq::exceptions::IOException(); } if (inputStream == NULL) { - throw NullPointerException(__FILE__, - __LINE__, - "InputStream passed is Null"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "InputStream passed is Null"); } decaf::util::Random randGen; @@ -160,11 +163,13 @@ class MyWireFormat : public wireformat::WireFormat catch (decaf::lang::Exception& ex) { ex.setMark(__FILE__, __LINE__); - throw IOException(); + throw activemq::exceptions::IOException(); } catch (...) { - throw IOException(__FILE__, __LINE__, "Catch all"); + throw activemq::exceptions::IOException(__FILE__, + __LINE__, + "Catch all"); } return command; @@ -172,13 +177,13 @@ class MyWireFormat : public wireformat::WireFormat } catch (decaf::lang::Exception& ex) { - IOException cx; + activemq::exceptions::IOException cx; cx.setMark(__FILE__, __LINE__); throw cx; } catch (...) { - IOException cx; + activemq::exceptions::IOException cx; cx.setMark(__FILE__, __LINE__); throw cx; } @@ -203,11 +208,13 @@ class MyWireFormat : public wireformat::WireFormat catch (decaf::lang::Exception& ex) { ex.setMark(__FILE__, __LINE__); - throw IOException(ex); + throw activemq::exceptions::IOException(ex); } catch (...) { - throw IOException(__FILE__, __LINE__, "writeCommand"); + throw activemq::exceptions::IOException(__FILE__, + __LINE__, + "writeCommand"); } } }; diff --git a/activemq-cpp/src/test/activemq/transport/TransportRegistryTest.cpp b/activemq-cpp/src/test/activemq/transport/TransportRegistryTest.cpp index babbade6c..2b96fb824 100644 --- a/activemq-cpp/src/test/activemq/transport/TransportRegistryTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/TransportRegistryTest.cpp @@ -17,15 +17,17 @@ #include +#include #include #include +#include using namespace activemq; +using namespace activemq::exceptions; using namespace activemq::transport; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class TransportRegistryTest : public ::testing::Test { @@ -43,12 +45,11 @@ TEST_F(TransportRegistryTest, test) ASSERT_NO_THROW(registry.findFactory("mock")); ASSERT_THROW(registry.findFactory(""), NoSuchElementException) - << ("Should have thrown an NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); - ASSERT_THROW(registry.registerFactory("test", NULL), NullPointerException) - << ("Should have thrown an NullPointerException"); + ASSERT_THROW(registry.registerFactory("test", NULL), std::logic_error) + << ("Should have thrown std::logic_error"); - ASSERT_THROW(registry.registerFactory("", &factory), - IllegalArgumentException) + ASSERT_THROW(registry.registerFactory("", &factory), std::invalid_argument) << ("Should have thrown an IllegalArgumentException"); } diff --git a/activemq-cpp/src/test/activemq/transport/correlator/ResponseCorrelatorTest.cpp b/activemq-cpp/src/test/activemq/transport/correlator/ResponseCorrelatorTest.cpp index c63cceb6a..2a804f17c 100644 --- a/activemq-cpp/src/test/activemq/transport/correlator/ResponseCorrelatorTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/correlator/ResponseCorrelatorTest.cpp @@ -23,10 +23,11 @@ #include #include #include -#include #include #include #include +#include +#include #include using namespace activemq; @@ -122,26 +123,23 @@ class MyTransport : public Transport, public decaf::lang::Runnable const std::shared_ptr command, const std::shared_ptr responseCallback) { - throw decaf::lang::exceptions::UnsupportedOperationException(__FILE__, - __LINE__, - "stuff"); + throw std::logic_error(std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + "stuff"); } virtual std::shared_ptr request( const std::shared_ptr command AMQCPP_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException(__FILE__, - __LINE__, - "stuff"); + throw std::logic_error(std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + "stuff"); } virtual std::shared_ptr request( const std::shared_ptr command AMQCPP_UNUSED, unsigned int timeout AMQCPP_UNUSED) { - throw decaf::lang::exceptions::UnsupportedOperationException(__FILE__, - __LINE__, - "stuff"); + throw std::logic_error(std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + "stuff"); } virtual std::shared_ptr getWireFormat() const @@ -526,7 +524,7 @@ TEST_F(ResponseCorrelatorTest, testTransportException) { correlator->request(cmd, 1000); } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { ASSERT_TRUE(false); } diff --git a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.cpp b/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.cpp index 62a809197..eef723b84 100644 --- a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentFactoryTest.cpp @@ -17,6 +17,7 @@ #include +#include #include #include #include @@ -24,13 +25,13 @@ #include using namespace activemq; +using namespace activemq::exceptions; using namespace activemq::transport; using namespace activemq::transport::discovery; using namespace decaf; using namespace decaf::util; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class AbstractDiscoveryAgentFactoryTest : public ::testing::Test { @@ -89,7 +90,7 @@ class MockDiscoveryAgent : public AbstractDiscoveryAgent Thread::sleep(500); } } - catch (InterruptedException& ex) + catch (InterruptedException&) { } } diff --git a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.cpp b/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.cpp index 161e4bd98..0b055f55e 100644 --- a/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/discovery/AbstractDiscoveryAgentTest.cpp @@ -17,6 +17,7 @@ #include +#include #include #include #include @@ -26,6 +27,7 @@ #include using namespace activemq; +using namespace activemq::exceptions; using namespace activemq::transport; using namespace activemq::transport::discovery; using namespace decaf; @@ -33,7 +35,6 @@ using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class AbstractDiscoveryAgentTest : public ::testing::Test { @@ -92,7 +93,7 @@ class MockDiscoveryAgent : public AbstractDiscoveryAgent Thread::sleep(500); } } - catch (InterruptedException& ex) + catch (InterruptedException&) { } } diff --git a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp index a98cb5e50..80ec0b09f 100644 --- a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp @@ -30,7 +30,6 @@ using namespace decaf; using namespace decaf::util; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class DiscoveryAgentRegistryTest : public ::testing::Test { diff --git a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp index 5fed053ce..067804cb2 100644 --- a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp @@ -32,7 +32,6 @@ using namespace decaf; using namespace decaf::util; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class DiscoveryTransportFactoryTest : public ::testing::Test { diff --git a/activemq-cpp/src/test/activemq/transport/failover/FailoverTransportTest.cpp b/activemq-cpp/src/test/activemq/transport/failover/FailoverTransportTest.cpp index 69d999c86..6eb7de4ee 100644 --- a/activemq-cpp/src/test/activemq/transport/failover/FailoverTransportTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/failover/FailoverTransportTest.cpp @@ -20,16 +20,19 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include #include +#include #include #include @@ -135,27 +138,26 @@ class PriorityBackupListener : public DefaultTransportListener virtual void transportInterrupted() { - std::shared_ptr latch; + // Count down while holding resetMutex so reset() cannot swap in new + // latches between taking the shared_ptr and countDown(); otherwise the + // test thread may await a latch that never receives the signal (flake). synchronized(&resetMutex) { - latch = interruptedLatch; - } - if (latch != NULL) - { - latch->countDown(); + if (interruptedLatch != NULL) + { + interruptedLatch->countDown(); + } } } virtual void transportResumed() { - std::shared_ptr latch; synchronized(&resetMutex) { - latch = resumedLatch; - } - if (latch != NULL) - { - latch->countDown(); + if (resumedLatch != NULL) + { + resumedLatch->countDown(); + } } } @@ -170,24 +172,107 @@ class PriorityBackupListener : public DefaultTransportListener bool awaitInterruption() { - std::shared_ptr latch; - synchronized(&resetMutex) + const long long deadline = System::currentTimeMillis() + 60000; + while (System::currentTimeMillis() < deadline) { - latch = interruptedLatch; + std::shared_ptr latch; + synchronized(&resetMutex) + { + latch = interruptedLatch; + } + if (latch->await(500)) + { + return true; + } } - bool result = latch->await(60000); - return result; + return false; } bool awaitResumed() { - std::shared_ptr latch; - synchronized(&resetMutex) + const long long deadline = System::currentTimeMillis() + 60000; + while (System::currentTimeMillis() < deadline) + { + std::shared_ptr latch; + synchronized(&resetMutex) + { + latch = resumedLatch; + } + if (latch->await(500)) + { + return true; + } + } + return false; + } +}; + +/** + * CI-stable listener for failover timing: CountDownLatch snapshots in + * awaitInterruption/awaitResumed can race with reset() and miss signals on + * loaded Linux/macOS runners. Atomic counters + spin wait avoid that. + */ +class FailoverSyncListener : public DefaultTransportListener +{ +private: + std::atomic interruptEvents; + std::atomic resumeEvents; + +public: + FailoverSyncListener() + : interruptEvents(0), + resumeEvents(0) + { + } + + virtual void transportInterrupted() override + { + interruptEvents.fetch_add(1, std::memory_order_relaxed); + } + + virtual void transportResumed() override + { + resumeEvents.fetch_add(1, std::memory_order_relaxed); + } + + int getInterruptEvents() const + { + return interruptEvents.load(std::memory_order_relaxed); + } + + int getResumeEvents() const + { + return resumeEvents.load(std::memory_order_relaxed); + } + + bool awaitInterruptEventsGreaterThan(int baseline, long long timeoutMs) + { + const int sliceMs = 50; + const long long deadline = System::currentTimeMillis() + timeoutMs; + while (System::currentTimeMillis() < deadline) { - latch = resumedLatch; + if (getInterruptEvents() > baseline) + { + return true; + } + Thread::sleep(sliceMs); } - bool result = latch->await(60000); - return result; + return getInterruptEvents() > baseline; + } + + bool awaitResumeEventsGreaterThan(int baseline, long long timeoutMs) + { + const int sliceMs = 50; + const long long deadline = System::currentTimeMillis() + timeoutMs; + while (System::currentTimeMillis() < deadline) + { + if (getResumeEvents() > baseline) + { + return true; + } + Thread::sleep(sliceMs); + } + return getResumeEvents() > baseline; } }; } // namespace @@ -397,7 +482,7 @@ TEST_F(FailoverTransportTest, testTransportCreateFailOnCreateSendMessage) transport->start(); - ASSERT_THROW(transport->oneway(message), IOException) + ASSERT_THROW(transport->oneway(message), activemq::exceptions::IOException) << ("Should Throw a IOException"); ASSERT_TRUE(listener.caughtException == true); @@ -929,7 +1014,7 @@ TEST_F(FailoverTransportTest, testMaxReconnectsHonorsConfiguration) transport->start(); - ASSERT_THROW(transport->oneway(info), Exception) + ASSERT_THROW(transport->oneway(info), activemq::exceptions::IOException) << ("Send should have failed after max connect attempts of two"); ASSERT_TRUE(failover->isConnected() == false); @@ -971,7 +1056,7 @@ TEST_F(FailoverTransportTest, testStartupMaxReconnectsHonorsConfiguration) // finished Thread::sleep(500); - ASSERT_THROW(transport->oneway(info), Exception) + ASSERT_THROW(transport->oneway(info), activemq::exceptions::IOException) << ("Send should have failed after max connect attempts of two"); ASSERT_TRUE(failover->isConnected() == false); @@ -2232,12 +2317,13 @@ TEST_F(FailoverTransportTest, testBrokerRestartWithProperSync) int port2 = broker2->getPort(); // Use 127.0.0.1 instead of localhost to avoid IPv6 resolution issues on CI - std::string uri = std::string("failover://(tcp://127.0.0.1:") + - Integer::toString(port1) + - ",tcp://127.0.0.1:" + Integer::toString(port2) + - ")?maxReconnectDelay=1000"; + std::string uri = + std::string("failover://(tcp://127.0.0.1:") + Integer::toString(port1) + + "?transport.useInactivityMonitor=false," + + "tcp://127.0.0.1:" + Integer::toString(port2) + + "?transport.useInactivityMonitor=false)?maxReconnectDelay=1000"; - PriorityBackupListener listener; + FailoverSyncListener listener; FailoverTransportFactory factory; std::shared_ptr transport(factory.create(uri)); @@ -2252,38 +2338,42 @@ TEST_F(FailoverTransportTest, testBrokerRestartWithProperSync) transport->start(); - // Wait for initial connection using listener, not sleep - ASSERT_TRUE(listener.awaitResumed()) << ("Failed to connect initially"); - listener.reset(); + ASSERT_TRUE(listener.awaitResumeEventsGreaterThan(0, 120000)) + << ("Failed to connect initially"); ASSERT_TRUE(failover->isConnected() == true); + int snapI = listener.getInterruptEvents(); + int snapR = listener.getResumeEvents(); + // Stop broker1, should failover to broker2 broker1->stop(); broker1->waitUntilStopped(); - ASSERT_TRUE(listener.awaitInterruption()) << ("Failed to get interrupted"); - ASSERT_TRUE(listener.awaitResumed()) << ("Failed to reconnect"); - listener.reset(); + ASSERT_TRUE(listener.awaitInterruptEventsGreaterThan(snapI, 120000)) + << ("Failed to get interrupted"); + ASSERT_TRUE(listener.awaitResumeEventsGreaterThan(snapR, 120000)) + << ("Failed to reconnect"); ASSERT_TRUE(failover->isConnected() == true); // Restart broker1 - wait for transport to be ready broker1->start(); broker1->waitUntilStarted(); - // Give backup connections time to establish (this is asynchronous in - // FailoverTransport) We can't eliminate this completely without modifying - // FailoverTransport to notify when backup connections are ready, but 3 - // seconds should be sufficient - Thread::sleep(3000); + // Give backup connections time to establish (asynchronous in + // FailoverTransport) + Thread::sleep(5000); + + snapI = listener.getInterruptEvents(); + snapR = listener.getResumeEvents(); // Stop broker2, should reconnect to broker1 broker2->stop(); broker2->waitUntilStopped(); - ASSERT_TRUE(listener.awaitInterruption()) + ASSERT_TRUE(listener.awaitInterruptEventsGreaterThan(snapI, 120000)) << ("Failed to get interrupted after broker2 stop"); - ASSERT_TRUE(listener.awaitResumed()) << ("Failed to reconnect to broker1"); - listener.reset(); + ASSERT_TRUE(listener.awaitResumeEventsGreaterThan(snapR, 120000)) + << ("Failed to reconnect to broker1"); // Now we're guaranteed to be connected before checking ASSERT_TRUE(failover->isConnected() == true) @@ -2294,7 +2384,7 @@ TEST_F(FailoverTransportTest, testBrokerRestartWithProperSync) broker2->waitUntilStarted(); // Give backup connections time to re-establish - Thread::sleep(3000); + Thread::sleep(5000); // Final check - we're still connected ASSERT_TRUE(failover->isConnected() == true) @@ -2331,11 +2421,13 @@ TEST_F(FailoverTransportTest, testFuzzyBrokerAvailability) // Use 127.0.0.1 instead of localhost to avoid IPv6 resolution issues on CI std::string uri = std::string("failover://(tcp://127.0.0.1:") + Integer::toString(port1) + - ",tcp://127.0.0.1:" + Integer::toString(port2) + - ")?initialReconnectDelay=100&maxReconnectDelay=500&" + "?transport.useInactivityMonitor=false," + + "tcp://127.0.0.1:" + Integer::toString(port2) + + "?transport.useInactivityMonitor=false)?" + "initialReconnectDelay=100&maxReconnectDelay=500&" "useExponentialBackOff=false"; - PriorityBackupListener listener; + FailoverSyncListener listener; FailoverTransportFactory factory; std::shared_ptr transport(factory.create(uri)); @@ -2350,17 +2442,10 @@ TEST_F(FailoverTransportTest, testFuzzyBrokerAvailability) transport->start(); - // Wait for initial connection with extended timeout - int retries = 0; - while (!listener.awaitResumed() && retries++ < 3) - { - Thread::sleep(1000); - } + ASSERT_TRUE(listener.awaitResumeEventsGreaterThan(0, 120000)) + << ("Failed to get reconnected in time"); ASSERT_TRUE(failover->isConnected()) << ("Failed to get reconnected in time"); - listener.reset(); - - ASSERT_TRUE(failover->isConnected() == true); std::random_device rd; std::mt19937 gen(rd()); @@ -2386,17 +2471,22 @@ TEST_F(FailoverTransportTest, testFuzzyBrokerAvailability) case 0: // Try to stop broker1 if (canStopBroker1) { + int snapI = listener.getInterruptEvents(); + int snapR = listener.getResumeEvents(); broker1->stop(); broker1->waitUntilStopped(); broker1Running = false; if (broker2Running) { - ASSERT_TRUE(listener.awaitInterruption()) + ASSERT_TRUE( + listener.awaitInterruptEventsGreaterThan(snapI, + 120000)) << ("Failed to get interrupted in time"); - ASSERT_TRUE(listener.awaitResumed()) + ASSERT_TRUE( + listener.awaitResumeEventsGreaterThan(snapR, + 120000)) << ("Failed to get reconnected in time"); - listener.reset(); } } break; @@ -2404,17 +2494,22 @@ TEST_F(FailoverTransportTest, testFuzzyBrokerAvailability) case 1: // Try to stop broker2 if (canStopBroker2) { + int snapI = listener.getInterruptEvents(); + int snapR = listener.getResumeEvents(); broker2->stop(); broker2->waitUntilStopped(); broker2Running = false; if (broker1Running) { - ASSERT_TRUE(listener.awaitInterruption()) + ASSERT_TRUE( + listener.awaitInterruptEventsGreaterThan(snapI, + 120000)) << ("Failed to get interrupted in time"); - ASSERT_TRUE(listener.awaitResumed()) + ASSERT_TRUE( + listener.awaitResumeEventsGreaterThan(snapR, + 120000)) << ("Failed to get reconnected in time"); - listener.reset(); } } break; @@ -2451,9 +2546,9 @@ TEST_F(FailoverTransportTest, testFuzzyBrokerAvailability) // is running if (broker1Running || broker2Running) { - // Allow some time for reconnection if needed + // Allow time for reconnection under slow CI (backoff can exceed 5s) int retries = 0; - while (!failover->isConnected() && retries < 50) + while (!failover->isConnected() && retries < 200) { Thread::sleep(100); retries++; @@ -2477,8 +2572,18 @@ TEST_F(FailoverTransportTest, testFuzzyBrokerAvailability) broker2Running = true; } - Thread::sleep(1000); - ASSERT_TRUE(failover->isConnected() == true); + // Reconnection after the fuzz loop can lag on busy CI; poll like the loop + // body instead of assuming 1s is always enough. + { + int retries = 0; + while (!failover->isConnected() && retries < 600) + { + Thread::sleep(100); + retries++; + } + } + ASSERT_TRUE(failover->isConnected()) + << ("Expected connected transport after both brokers are up"); transport->close(); diff --git a/activemq-cpp/src/test/activemq/transport/inactivity/InactivityMonitorTest.cpp b/activemq-cpp/src/test/activemq/transport/inactivity/InactivityMonitorTest.cpp index 71ef4e926..287237c91 100644 --- a/activemq-cpp/src/test/activemq/transport/inactivity/InactivityMonitorTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/inactivity/InactivityMonitorTest.cpp @@ -41,7 +41,6 @@ using namespace decaf; using namespace decaf::net; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class InactivityMonitorTest : public ::testing::Test { diff --git a/activemq-cpp/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp b/activemq-cpp/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp index aad2ec4d1..e3ca29e70 100644 --- a/activemq-cpp/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp @@ -29,7 +29,6 @@ using namespace activemq::transport::mock; using namespace decaf; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class MockTransportFactoryTest : public ::testing::Test { diff --git a/activemq-cpp/src/test/activemq/transport/tcp/SslTransportTest.cpp b/activemq-cpp/src/test/activemq/transport/tcp/SslTransportTest.cpp index 44ba5ed7f..13f640fd2 100644 --- a/activemq-cpp/src/test/activemq/transport/tcp/SslTransportTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/tcp/SslTransportTest.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -310,7 +311,15 @@ TEST_F(SslTransportTest, testSslConnectionFailureHandling) { sslTransport->start(); } - catch (decaf::io::IOException& ex) + catch (activemq::exceptions::IOException&) + { + exceptionCaught = true; + } + catch (activemq::exceptions::ActiveMQException&) + { + exceptionCaught = true; + } + catch (decaf::io::IOException&) { exceptionCaught = true; } diff --git a/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.cpp b/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.cpp index 60717d1bf..f9cfbc3c9 100644 --- a/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.cpp +++ b/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.cpp @@ -17,6 +17,8 @@ #include +#include + #include #include @@ -195,7 +197,7 @@ class TestServer : public lang::Thread // flag continue; } - catch (IOException& io) + catch (activemq::exceptions::IOException& io) { // IOException during accept usually means socket was closed // Check if we're shutting down @@ -209,7 +211,7 @@ class TestServer : public lang::Thread } } } - catch (IOException& ex) + catch (activemq::exceptions::IOException& ex) { // Only set error if not shutting down if (!done) @@ -261,31 +263,51 @@ void TcpTransportTest::TearDown() //////////////////////////////////////////////////////////////////////////////// TEST_F(TcpTransportTest, testTransportCreateWithRadomFailures) { - Properties properties; - OpenWireFormat wireFormat(properties); TcpTransportFactory factory; int port = server->getLocalPort(); - URI connectUri("tcp://localhost:" + Integer::toString(port)); - - std::shared_ptr transport; - - // Test rapid creation with random connect failures. + // Use IPv4 loopback: on Linux CI "localhost" often resolves to ::1 first, + // which can behave differently from IPv4 and amplify races with rapid + // connects; ServerSocket is bound to all interfaces on IPv4. + URI connectUri("tcp://127.0.0.1:" + Integer::toString(port)); + + // Rapid creation with random connect failures on the server side. + // Each iteration must use its own transport: if create() throws, we must + // not call start()/close() on null or on a transport from a previous + // iteration. for (int i = 0; i < 1000; ++i) { + std::shared_ptr transport; try { transport = factory.create(connectUri); } - catch (Exception& ex) + catch (Exception&) + { + } + catch (std::exception&) + { + } + catch (...) + { + } + + if (!transport) { + continue; } try { transport->start(); } - catch (Exception& ex) + catch (Exception&) + { + } + catch (std::exception&) + { + } + catch (...) { } @@ -293,7 +315,13 @@ TEST_F(TcpTransportTest, testTransportCreateWithRadomFailures) { transport->close(); } - catch (Exception& ex) + catch (Exception&) + { + } + catch (std::exception&) + { + } + catch (...) { } } diff --git a/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.cpp b/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.cpp index c7c9d8cc8..c8fec4863 100644 --- a/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.cpp +++ b/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.cpp @@ -26,14 +26,13 @@ #include #include -#include +#include using namespace activemq; using namespace activemq::util; using namespace activemq::commands; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class ActiveMQMessageTransformationTest : public ::testing::Test { @@ -102,18 +101,18 @@ TEST_F(ActiveMQMessageTransformationTest, testTransformDestination) ASSERT_THROW( ActiveMQMessageTransformation::transformDestination(&customTopic, NULL), - NullPointerException) - << ("Should throw an NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_THROW( ActiveMQMessageTransformation::transformDestination(NULL, NULL), - NullPointerException) - << ("Should throw an NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_THROW( ActiveMQMessageTransformation::transformDestination(NULL, &transformed), - NullPointerException) - << ("Should throw an NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_TRUE( ActiveMQMessageTransformation::transformDestination(&customTopic, diff --git a/activemq-cpp/src/test/activemq/util/AdvisorySupportTest.cpp b/activemq-cpp/src/test/activemq/util/AdvisorySupportTest.cpp index 8056bb42e..3c26ef737 100644 --- a/activemq-cpp/src/test/activemq/util/AdvisorySupportTest.cpp +++ b/activemq-cpp/src/test/activemq/util/AdvisorySupportTest.cpp @@ -24,15 +24,12 @@ #include #include -#include #include +#include using namespace activemq; using namespace activemq::util; using namespace activemq::commands; -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; class AdvisorySupportTest : public ::testing::Test { @@ -117,13 +114,13 @@ TEST_F(AdvisorySupportTest, testGetAllDestinationAdvisoryTopics) ASSERT_THROW(AdvisorySupport::getAllDestinationAdvisoryTopics( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::getAllDestinationAdvisoryTopics( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -240,13 +237,13 @@ TEST_F(AdvisorySupportTest, testGetConsumerAdvisoryTopic) ASSERT_THROW( AdvisorySupport::getConsumerAdvisoryTopic((ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::getConsumerAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -285,13 +282,13 @@ TEST_F(AdvisorySupportTest, testGetProducerAdvisoryTopic) ASSERT_THROW( AdvisorySupport::getProducerAdvisoryTopic((ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::getProducerAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -367,13 +364,13 @@ TEST_F(AdvisorySupportTest, testGetExpiredMessageTopic) ASSERT_THROW( AdvisorySupport::getExpiredMessageTopic((ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::getExpiredMessageTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -412,13 +409,13 @@ TEST_F(AdvisorySupportTest, testGetExpiredTopicMessageAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getExpiredTopicMessageAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::getExpiredTopicMessageAdvisoryTopic( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -457,13 +454,13 @@ TEST_F(AdvisorySupportTest, testGetExpiredQueueMessageAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getExpiredQueueMessageAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::getExpiredQueueMessageAdvisoryTopic( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -535,13 +532,13 @@ TEST_F(AdvisorySupportTest, testGetNoConsumersAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getNoConsumersAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::getNoConsumersAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -580,13 +577,13 @@ TEST_F(AdvisorySupportTest, testGetNoTopicConsumersAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getNoTopicConsumersAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::getNoTopicConsumersAdvisoryTopic( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -625,13 +622,13 @@ TEST_F(AdvisorySupportTest, testGetNoQueueConsumersAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getNoQueueConsumersAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::getNoQueueConsumersAdvisoryTopic( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -670,13 +667,13 @@ TEST_F(AdvisorySupportTest, testGetSlowConsumerAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getSlowConsumerAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::getSlowConsumerAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -715,13 +712,13 @@ TEST_F(AdvisorySupportTest, testGetFastProducerAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getFastProducerAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::getFastProducerAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -760,13 +757,13 @@ TEST_F(AdvisorySupportTest, testGetMessageDiscardedAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getMessageDiscardedAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::getMessageDiscardedAdvisoryTopic( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -805,13 +802,13 @@ TEST_F(AdvisorySupportTest, testGetMessageDeliveredAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getMessageDeliveredAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::getMessageDeliveredAdvisoryTopic( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -850,13 +847,13 @@ TEST_F(AdvisorySupportTest, testGetMessageConsumedAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getMessageConsumedAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::getMessageConsumedAdvisoryTopic( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -895,13 +892,13 @@ TEST_F(AdvisorySupportTest, testGetMessageDLQdAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getMessageDLQdAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::getMessageDLQdAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -968,12 +965,12 @@ TEST_F(AdvisorySupportTest, testGetFullAdvisoryTopic) ASSERT_THROW( AdvisorySupport::getFullAdvisoryTopic((ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::getFullAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1011,13 +1008,13 @@ TEST_F(AdvisorySupportTest, testGetDestinationAdvisoryTopic) ASSERT_THROW(AdvisorySupport::getDestinationAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::getDestinationAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1040,13 +1037,13 @@ TEST_F(AdvisorySupportTest, testIsDestinationAdvisoryTopic) ASSERT_THROW( AdvisorySupport::isDestinationAdvisoryTopic((ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::isDestinationAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1071,13 +1068,13 @@ TEST_F(AdvisorySupportTest, testIsTempDestinationAdvisoryTopic) ASSERT_THROW(AdvisorySupport::isTempDestinationAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::isTempDestinationAdvisoryTopic( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1099,12 +1096,12 @@ TEST_F(AdvisorySupportTest, testIsAdvisoryTopic) ASSERT_TRUE(AdvisorySupport::isAdvisoryTopic(cmstopic.get())); ASSERT_THROW(AdvisorySupport::isAdvisoryTopic((ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::isAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1127,13 +1124,13 @@ TEST_F(AdvisorySupportTest, testIsConnectionAdvisoryTopic) ASSERT_THROW( AdvisorySupport::isConnectionAdvisoryTopic((ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::isConnectionAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1156,13 +1153,13 @@ TEST_F(AdvisorySupportTest, testIsProducerAdvisoryTopic) ASSERT_THROW( AdvisorySupport::isProducerAdvisoryTopic((ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::isProducerAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1185,13 +1182,13 @@ TEST_F(AdvisorySupportTest, testIsConsumerAdvisoryTopic) ASSERT_THROW( AdvisorySupport::isConsumerAdvisoryTopic((ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::isConsumerAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1214,13 +1211,13 @@ TEST_F(AdvisorySupportTest, testIsSlowConsumerAdvisoryTopic) ASSERT_THROW(AdvisorySupport::isSlowConsumerAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::isSlowConsumerAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1243,13 +1240,13 @@ TEST_F(AdvisorySupportTest, testIsFastProducerAdvisoryTopic) ASSERT_THROW(AdvisorySupport::isFastProducerAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::isFastProducerAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1274,13 +1271,13 @@ TEST_F(AdvisorySupportTest, testIsMessageConsumedAdvisoryTopic) ASSERT_THROW(AdvisorySupport::isMessageConsumedAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::isMessageConsumedAdvisoryTopic( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1303,13 +1300,13 @@ TEST_F(AdvisorySupportTest, testIsMasterBrokerAdvisoryTopic) ASSERT_THROW(AdvisorySupport::isMasterBrokerAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::isMasterBrokerAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1335,13 +1332,13 @@ TEST_F(AdvisorySupportTest, testIsMessageDeliveredAdvisoryTopic) ASSERT_THROW(AdvisorySupport::isMessageDeliveredAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::isMessageDeliveredAdvisoryTopic( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1367,13 +1364,13 @@ TEST_F(AdvisorySupportTest, testIsMessageDiscardedAdvisoryTopic) ASSERT_THROW(AdvisorySupport::isMessageDiscardedAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::isMessageDiscardedAdvisoryTopic( (cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1396,13 +1393,13 @@ TEST_F(AdvisorySupportTest, testIsMessageDLQdAdvisoryTopic) ASSERT_THROW( AdvisorySupport::isMessageDLQdAdvisoryTopic((ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::isMessageDLQdAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1425,12 +1422,12 @@ TEST_F(AdvisorySupportTest, testIsFullAdvisoryTopic) ASSERT_THROW( AdvisorySupport::isFullAdvisoryTopic((ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW(AdvisorySupport::isFullAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } @@ -1453,12 +1450,12 @@ TEST_F(AdvisorySupportTest, testIsNetworkBridgeAdvisoryTopic) ASSERT_THROW(AdvisorySupport::isNetworkBridgeAdvisoryTopic( (ActiveMQDestination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); ASSERT_THROW( AdvisorySupport::isNetworkBridgeAdvisoryTopic((cms::Destination*)NULL), - NullPointerException) - << ("Should throw a NullPointerException when passed a NULL " + std::logic_error) + << ("Should throw std::logic_error when passed a NULL " "destination"); } diff --git a/activemq-cpp/src/test/activemq/util/MarshallingSupportTest.cpp b/activemq-cpp/src/test/activemq/util/MarshallingSupportTest.cpp index 3f4423c1b..55d3ecb49 100644 --- a/activemq-cpp/src/test/activemq/util/MarshallingSupportTest.cpp +++ b/activemq-cpp/src/test/activemq/util/MarshallingSupportTest.cpp @@ -245,7 +245,7 @@ TEST_F(MarshallingSupportTest, testModifiedUtf8ToAscii) (int)sizeof(input) / (int)sizeof(unsigned char)); ASSERT_THROW(MarshallingSupport::modifiedUtf8ToAscii(inputString), - UTFDataFormatException) + activemq::exceptions::UTFDataFormatException) << ("Should throw a UTFDataFormatException"); } @@ -269,7 +269,7 @@ TEST_F(MarshallingSupportTest, testModifiedUtf8ToAscii) (int)sizeof(input) / (int)sizeof(unsigned char)); ASSERT_THROW(MarshallingSupport::modifiedUtf8ToAscii(inputString), - UTFDataFormatException) + activemq::exceptions::UTFDataFormatException) << ("Should throw a UTFDataFormatException"); } @@ -281,7 +281,7 @@ TEST_F(MarshallingSupportTest, testModifiedUtf8ToAscii) (int)sizeof(input) / (int)sizeof(unsigned char)); ASSERT_THROW(MarshallingSupport::modifiedUtf8ToAscii(inputString), - UTFDataFormatException) + activemq::exceptions::UTFDataFormatException) << ("Should throw a UTFDataFormatException"); } @@ -293,7 +293,7 @@ TEST_F(MarshallingSupportTest, testModifiedUtf8ToAscii) (int)sizeof(input) / (int)sizeof(unsigned char)); ASSERT_THROW(MarshallingSupport::modifiedUtf8ToAscii(inputString), - UTFDataFormatException) + activemq::exceptions::UTFDataFormatException) << ("Should throw a UTFDataFormatException"); } @@ -305,7 +305,7 @@ TEST_F(MarshallingSupportTest, testModifiedUtf8ToAscii) (int)sizeof(input) / (int)sizeof(unsigned char)); ASSERT_THROW(MarshallingSupport::modifiedUtf8ToAscii(inputString), - UTFDataFormatException) + activemq::exceptions::UTFDataFormatException) << ("Should throw a UTFDataFormatException"); } } diff --git a/activemq-cpp/src/test/activemq/util/PrimitiveListTest.cpp b/activemq-cpp/src/test/activemq/util/PrimitiveListTest.cpp index 1650b24d7..7414554a4 100644 --- a/activemq-cpp/src/test/activemq/util/PrimitiveListTest.cpp +++ b/activemq-cpp/src/test/activemq/util/PrimitiveListTest.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using namespace activemq; using namespace activemq::util; @@ -33,9 +34,8 @@ TEST_F(PrimitiveListTest, testSetGet) { PrimitiveList plist; - ASSERT_THROW(plist.getBool(0), - decaf::lang::exceptions::IndexOutOfBoundsException) - << ("Should Throw IndexOutOfBoundsException"); + ASSERT_THROW(plist.getBool(0), std::out_of_range) + << ("Should Throw std::out_of_range"); plist.add(true); ASSERT_TRUE(plist.getBool(0) == true); @@ -44,59 +44,51 @@ TEST_F(PrimitiveListTest, testSetGet) ASSERT_TRUE(plist.getBool(1) == false); ASSERT_TRUE(plist.getString(1) == "false"); - ASSERT_THROW(plist.getByte(0), - decaf::lang::exceptions::UnsupportedOperationException) + ASSERT_THROW(plist.getByte(0), std::logic_error) << ("Should Throw UnsupportedOperationException"); plist.setByte(0, 1); ASSERT_TRUE(plist.getByte(0) == 1); - ASSERT_THROW(plist.getChar(0), - decaf::lang::exceptions::UnsupportedOperationException) + ASSERT_THROW(plist.getChar(0), std::logic_error) << ("Should Throw UnsupportedOperationException"); plist.setChar(0, 'a'); ASSERT_TRUE(plist.getChar(0) == 'a'); ASSERT_TRUE(plist.getString(0) == "a"); - ASSERT_THROW(plist.getShort(0), - decaf::lang::exceptions::UnsupportedOperationException) + ASSERT_THROW(plist.getShort(0), std::logic_error) << ("Should Throw UnsupportedOperationException"); plist.setShort(0, 2); ASSERT_TRUE(plist.getShort(0) == 2); ASSERT_TRUE(plist.getInt(0) == 2); - ASSERT_THROW(plist.getByte(0), - decaf::lang::exceptions::UnsupportedOperationException) + ASSERT_THROW(plist.getByte(0), std::logic_error) << ("Should Throw UnsupportedOperationException"); plist.setInt(0, 3); ASSERT_TRUE(plist.getInt(0) == 3); - ASSERT_THROW(plist.getShort(0), - decaf::lang::exceptions::UnsupportedOperationException) + ASSERT_THROW(plist.getShort(0), std::logic_error) << ("Should Throw UnsupportedOperationException"); plist.setLong(0, 4L); ASSERT_TRUE(plist.getLong(0) == 4L); - ASSERT_THROW(plist.getDouble(0), - decaf::lang::exceptions::UnsupportedOperationException) + ASSERT_THROW(plist.getDouble(0), std::logic_error) << ("Should Throw UnsupportedOperationException"); plist.setDouble(0, 2.3); ASSERT_TRUE(plist.getDouble(0) == 2.3); - ASSERT_THROW(plist.getFloat(0), - decaf::lang::exceptions::UnsupportedOperationException) + ASSERT_THROW(plist.getFloat(0), std::logic_error) << ("Should Throw UnsupportedOperationException"); plist.setFloat(0, 3.2f); ASSERT_TRUE(plist.getFloat(0) == 3.2f); - ASSERT_THROW(plist.getChar(0), - decaf::lang::exceptions::UnsupportedOperationException) + ASSERT_THROW(plist.getChar(0), std::logic_error) << ("Should Throw UnsupportedOperationException"); plist.setString(0, "hello"); @@ -108,8 +100,7 @@ TEST_F(PrimitiveListTest, testSetGet) byteArray.push_back('c'); byteArray.push_back('d'); - ASSERT_THROW(plist.getByteArray(0), - decaf::lang::exceptions::UnsupportedOperationException) + ASSERT_THROW(plist.getByteArray(0), std::logic_error) << ("Should Throw UnsupportedOperationException"); plist.setByteArray(0, byteArray); @@ -146,13 +137,11 @@ TEST_F(PrimitiveListTest, testAdd) plist.add(stringValue); plist.add(byteArrayValue); - ASSERT_THROW(plist.getInt(0), - decaf::lang::exceptions::UnsupportedOperationException) + ASSERT_THROW(plist.getInt(0), std::logic_error) << ("Should Throw UnsupportedOperationException"); - ASSERT_THROW(plist.getInt(plist.size()), - decaf::lang::exceptions::IndexOutOfBoundsException) - << ("Should Throw IndexOutOfBoundsException"); + ASSERT_THROW(plist.getInt(plist.size()), std::out_of_range) + << ("Should Throw std::out_of_range"); ASSERT_TRUE(plist.get(0).getType() == PrimitiveValueNode::BOOLEAN_TYPE); ASSERT_TRUE(plist.get(1).getType() == PrimitiveValueNode::BYTE_TYPE); @@ -175,8 +164,7 @@ TEST_F(PrimitiveListTest, testRemove) plist.add(6); plist.removeAt(0); - ASSERT_THROW(plist.getInt(0), - decaf::lang::exceptions::UnsupportedOperationException) + ASSERT_THROW(plist.getInt(0), std::logic_error) << ("Should Throw UnsupportedOperationException"); plist.removeAt(0); @@ -229,17 +217,14 @@ TEST_F(PrimitiveListTest, testClear) plist.clear(); ASSERT_TRUE(plist.size() == 0); - ASSERT_THROW(plist.getInt(0), - decaf::lang::exceptions::IndexOutOfBoundsException) - << ("Should Throw IndexOutOfBoundsException"); + ASSERT_THROW(plist.getInt(0), std::out_of_range) + << ("Should Throw std::out_of_range"); - ASSERT_THROW(plist.getFloat(1), - decaf::lang::exceptions::IndexOutOfBoundsException) - << ("Should Throw IndexOutOfBoundsException"); + ASSERT_THROW(plist.getFloat(1), std::out_of_range) + << ("Should Throw std::out_of_range"); - ASSERT_THROW(plist.getInt(2), - decaf::lang::exceptions::IndexOutOfBoundsException) - << ("Should Throw IndexOutOfBoundsException"); + ASSERT_THROW(plist.getInt(2), std::out_of_range) + << ("Should Throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.cpp b/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.cpp index 768205413..9c23cf042 100644 --- a/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.cpp +++ b/activemq-cpp/src/test/activemq/util/PrimitiveMapTest.cpp @@ -17,10 +17,12 @@ #include +#include #include #include using namespace activemq; +using namespace activemq::exceptions; using namespace activemq::util; class PrimitiveMapTest : public ::testing::Test @@ -86,7 +88,7 @@ TEST_F(PrimitiveMapTest, testValueNode) node.getFloat(); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } @@ -104,7 +106,7 @@ TEST_F(PrimitiveMapTest, testSetGet) pmap.getBool("bool"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } pmap.setBool("bool", true); @@ -117,7 +119,7 @@ TEST_F(PrimitiveMapTest, testSetGet) pmap.getByte("byte"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } pmap.setByte("byte", 1); @@ -129,7 +131,7 @@ TEST_F(PrimitiveMapTest, testSetGet) pmap.getChar("char"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } pmap.setChar("char", 'a'); @@ -141,7 +143,7 @@ TEST_F(PrimitiveMapTest, testSetGet) pmap.getShort("short"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } pmap.setShort("short", 2); @@ -153,7 +155,7 @@ TEST_F(PrimitiveMapTest, testSetGet) pmap.getInt("int"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } pmap.setInt("int", 3); @@ -165,7 +167,7 @@ TEST_F(PrimitiveMapTest, testSetGet) pmap.getLong("long"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } pmap.setLong("long", 4L); @@ -177,7 +179,7 @@ TEST_F(PrimitiveMapTest, testSetGet) pmap.getDouble("double"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } pmap.setDouble("double", 2.3); @@ -189,7 +191,7 @@ TEST_F(PrimitiveMapTest, testSetGet) pmap.getFloat("float"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } pmap.setFloat("float", 3.2f); @@ -201,7 +203,7 @@ TEST_F(PrimitiveMapTest, testSetGet) pmap.getString("string"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } pmap.setString("string", "hello"); @@ -218,7 +220,7 @@ TEST_F(PrimitiveMapTest, testSetGet) pmap.getByteArray("byteArray"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } pmap.setByteArray("byteArray", byteArray); @@ -238,7 +240,7 @@ TEST_F(PrimitiveMapTest, testRemove) pmap.getInt("int"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } } @@ -292,7 +294,7 @@ TEST_F(PrimitiveMapTest, testClear) pmap.getInt("int"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } @@ -301,7 +303,7 @@ TEST_F(PrimitiveMapTest, testClear) pmap.getFloat("float"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } @@ -310,7 +312,7 @@ TEST_F(PrimitiveMapTest, testClear) pmap.getInt("int2"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } } diff --git a/activemq-cpp/src/test/activemq/util/PrimitiveValueConverterTest.cpp b/activemq-cpp/src/test/activemq/util/PrimitiveValueConverterTest.cpp index fab23f0db..b3c3a5fd3 100644 --- a/activemq-cpp/src/test/activemq/util/PrimitiveValueConverterTest.cpp +++ b/activemq-cpp/src/test/activemq/util/PrimitiveValueConverterTest.cpp @@ -18,11 +18,10 @@ #include #include -#include +#include using namespace activemq; using namespace activemq::util; -using namespace decaf::lang::exceptions; class PrimitiveValueConverterTest : public ::testing::Test { @@ -48,7 +47,7 @@ TEST_F(PrimitiveValueConverterTest, testConvertToBoolean) ASSERT_TRUE(result3 == true); ASSERT_TRUE(result4 == false); - ASSERT_THROW(converter.convert(input5), UnsupportedOperationException) + ASSERT_THROW(converter.convert(input5), std::logic_error) << ("Should throw an UnsupportedOperationException"); } @@ -70,9 +69,9 @@ TEST_F(PrimitiveValueConverterTest, testConvertToChar) ASSERT_TRUE(result2 == (char)255); ASSERT_TRUE(result3 == 'a'); - ASSERT_THROW(converter.convert(input4), UnsupportedOperationException) + ASSERT_THROW(converter.convert(input4), std::logic_error) << ("Should throw an UnsupportedOperationException"); - ASSERT_THROW(converter.convert(input5), UnsupportedOperationException) + ASSERT_THROW(converter.convert(input5), std::logic_error) << ("Should throw an UnsupportedOperationException"); } @@ -94,11 +93,9 @@ TEST_F(PrimitiveValueConverterTest, testConvertToByte) ASSERT_TRUE(result2 == (unsigned char)255); ASSERT_TRUE(result3 == (unsigned char)4); - ASSERT_THROW(converter.convert(input4), - UnsupportedOperationException) + ASSERT_THROW(converter.convert(input4), std::logic_error) << ("Should throw an UnsupportedOperationException"); - ASSERT_THROW(converter.convert(input5), - UnsupportedOperationException) + ASSERT_THROW(converter.convert(input5), std::logic_error) << ("Should throw an UnsupportedOperationException"); } @@ -120,9 +117,9 @@ TEST_F(PrimitiveValueConverterTest, testConvertToShort) ASSERT_TRUE(result2 == (short)65535); ASSERT_TRUE(result3 == 4); - ASSERT_THROW(converter.convert(input4), UnsupportedOperationException) + ASSERT_THROW(converter.convert(input4), std::logic_error) << ("Should throw an UnsupportedOperationException"); - ASSERT_THROW(converter.convert(input5), UnsupportedOperationException) + ASSERT_THROW(converter.convert(input5), std::logic_error) << ("Should throw an UnsupportedOperationException"); } @@ -147,9 +144,9 @@ TEST_F(PrimitiveValueConverterTest, testConvertToInt) ASSERT_TRUE(result3 == -1); ASSERT_TRUE(result4 == 4); - ASSERT_THROW(converter.convert(input5), UnsupportedOperationException) + ASSERT_THROW(converter.convert(input5), std::logic_error) << ("Should throw an UnsupportedOperationException"); - ASSERT_THROW(converter.convert(input6), UnsupportedOperationException) + ASSERT_THROW(converter.convert(input6), std::logic_error) << ("Should throw an UnsupportedOperationException"); } @@ -177,11 +174,9 @@ TEST_F(PrimitiveValueConverterTest, testConvertToLong) ASSERT_TRUE(result4 == 4); ASSERT_TRUE(result5 == 45LL); - ASSERT_THROW(converter.convert(input6), - UnsupportedOperationException) + ASSERT_THROW(converter.convert(input6), std::logic_error) << ("Should throw an UnsupportedOperationException"); - ASSERT_THROW(converter.convert(input7), - UnsupportedOperationException) + ASSERT_THROW(converter.convert(input7), std::logic_error) << ("Should throw an UnsupportedOperationException"); } @@ -203,9 +198,9 @@ TEST_F(PrimitiveValueConverterTest, testConvertToFloat) ASSERT_TRUE(result2 == 135.0f); ASSERT_TRUE(result3 == 4.0); - ASSERT_THROW(converter.convert(input4), UnsupportedOperationException) + ASSERT_THROW(converter.convert(input4), std::logic_error) << ("Should throw an UnsupportedOperationException"); - ASSERT_THROW(converter.convert(input5), UnsupportedOperationException) + ASSERT_THROW(converter.convert(input5), std::logic_error) << ("Should throw an UnsupportedOperationException"); } @@ -227,11 +222,9 @@ TEST_F(PrimitiveValueConverterTest, testConvertToDouble) ASSERT_TRUE(result2 == (double)135.0); ASSERT_TRUE(result3 == (double)4); - ASSERT_THROW(converter.convert(input4), - UnsupportedOperationException) + ASSERT_THROW(converter.convert(input4), std::logic_error) << ("Should throw an UnsupportedOperationException"); - ASSERT_THROW(converter.convert(input5), - UnsupportedOperationException) + ASSERT_THROW(converter.convert(input5), std::logic_error) << ("Should throw an UnsupportedOperationException"); } @@ -263,7 +256,6 @@ TEST_F(PrimitiveValueConverterTest, testConvertToString) ASSERT_TRUE(result6 == "4asd"); ASSERT_TRUE(result7 == "65539"); - ASSERT_THROW(converter.convert(24567), - UnsupportedOperationException) + ASSERT_THROW(converter.convert(24567), std::logic_error) << ("Should throw an UnsupportedOperationException"); } diff --git a/activemq-cpp/src/test/activemq/util/PrimitiveValueNodeTest.cpp b/activemq-cpp/src/test/activemq/util/PrimitiveValueNodeTest.cpp index 4f816a2d4..824ed1698 100644 --- a/activemq-cpp/src/test/activemq/util/PrimitiveValueNodeTest.cpp +++ b/activemq-cpp/src/test/activemq/util/PrimitiveValueNodeTest.cpp @@ -17,9 +17,11 @@ #include +#include #include using namespace activemq; +using namespace activemq::exceptions; using namespace activemq::util; class PrimitiveValueNodeTest : public ::testing::Test @@ -85,7 +87,7 @@ TEST_F(PrimitiveValueNodeTest, testValueNode) node.getFloat(); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } diff --git a/activemq-cpp/src/test/activemq/util/URISupportTest.cpp b/activemq-cpp/src/test/activemq/util/URISupportTest.cpp index dc075f90b..7a9a652c8 100644 --- a/activemq-cpp/src/test/activemq/util/URISupportTest.cpp +++ b/activemq-cpp/src/test/activemq/util/URISupportTest.cpp @@ -19,8 +19,8 @@ #include #include -#include #include +#include using namespace std; using namespace decaf; @@ -137,28 +137,23 @@ TEST_F(URISupportTest, testURIParseEnv) ASSERT_TRUE(map.getProperty("option2", "") == "test2"); test = "tcp://localhost:61616?option1=test1&option2=${TEST_CPP_AMQ_XXX}"; - ASSERT_THROW(URISupport::parseURL(test, map), - decaf::lang::exceptions::IllegalArgumentException) + ASSERT_THROW(URISupport::parseURL(test, map), std::invalid_argument) << ("Should Throw an IllegalArgumentException"); test = "tcp://localhost:61616?option1=test1&option2=${}"; - ASSERT_THROW(URISupport::parseURL(test, map), - decaf::lang::exceptions::IllegalArgumentException) + ASSERT_THROW(URISupport::parseURL(test, map), std::invalid_argument) << ("Should Throw an IllegalArgumentException"); test = "tcp://localhost:61616?option1=test1&option2=$X}"; - ASSERT_THROW(URISupport::parseURL(test, map), - decaf::lang::exceptions::IllegalArgumentException) + ASSERT_THROW(URISupport::parseURL(test, map), std::invalid_argument) << ("Should Throw an IllegalArgumentException"); test = "tcp://localhost:61616?option1=test1&option2=${X"; - ASSERT_THROW(URISupport::parseURL(test, map), - decaf::lang::exceptions::IllegalArgumentException) + ASSERT_THROW(URISupport::parseURL(test, map), std::invalid_argument) << ("Should Throw an IllegalArgumentException"); test = "tcp://localhost:61616?option1=test1&option2=$X"; - ASSERT_THROW(URISupport::parseURL(test, map), - decaf::lang::exceptions::IllegalArgumentException) + ASSERT_THROW(URISupport::parseURL(test, map), std::invalid_argument) << ("Should Throw an IllegalArgumentException"); } diff --git a/activemq-cpp/src/test/activemq/wireformat/WireFormatRegistryTest.cpp b/activemq-cpp/src/test/activemq/wireformat/WireFormatRegistryTest.cpp index 19a781736..e76a5c467 100644 --- a/activemq-cpp/src/test/activemq/wireformat/WireFormatRegistryTest.cpp +++ b/activemq-cpp/src/test/activemq/wireformat/WireFormatRegistryTest.cpp @@ -17,16 +17,17 @@ #include +#include #include #include +#include using namespace activemq; +using namespace activemq::exceptions; using namespace activemq::wireformat; using namespace decaf; using namespace decaf::util; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; class WireFormatRegistryTest : public ::testing::Test { @@ -44,12 +45,11 @@ TEST_F(WireFormatRegistryTest, test) ASSERT_NO_THROW(registry.findFactory("openwire")); ASSERT_THROW(registry.findFactory(""), NoSuchElementException) - << ("Should have thrown an NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); - ASSERT_THROW(registry.registerFactory("test", NULL), NullPointerException) - << ("Should have thrown an NullPointerException"); + ASSERT_THROW(registry.registerFactory("test", NULL), std::logic_error) + << ("Should have thrown std::logic_error"); - ASSERT_THROW(registry.registerFactory("", &factory), - IllegalArgumentException) - << ("Should have thrown an IllegalArgumentException"); + ASSERT_THROW(registry.registerFactory("", &factory), std::invalid_argument) + << ("Should have thrown an std::invalid_argument"); } diff --git a/activemq-cpp/src/test/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshallerTest.cpp b/activemq-cpp/src/test/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshallerTest.cpp index 1e65b9289..1f5babdd5 100644 --- a/activemq-cpp/src/test/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshallerTest.cpp +++ b/activemq-cpp/src/test/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshallerTest.cpp @@ -25,7 +25,6 @@ using namespace std; using namespace activemq; using namespace activemq::util; using namespace decaf::io; -using namespace decaf::lang::exceptions; using namespace activemq::wireformat; using namespace activemq::wireformat::openwire; using namespace activemq::wireformat::openwire::marshal; diff --git a/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.cpp b/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.cpp index f7d6a3530..50cfaae4b 100644 --- a/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.cpp +++ b/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace decaf { @@ -37,7 +38,7 @@ using namespace decaf; using namespace decaf::nio; using namespace decaf::internal::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; class ByteArrayBufferTest : public ::testing::Test { @@ -142,10 +143,10 @@ TEST_F(ByteArrayBufferTest, testReadOnlyArray) ASSERT_TRUE(readOnly != NULL); ASSERT_TRUE(readOnly->isReadOnly() == true); - ASSERT_THROW(readOnly->array(), UnsupportedOperationException) + ASSERT_THROW(readOnly->array(), std::logic_error) << ("Should throw UnsupportedOperationException"); - ASSERT_THROW(readOnly->arrayOffset(), UnsupportedOperationException) + ASSERT_THROW(readOnly->arrayOffset(), std::logic_error) << ("Should throw UnsupportedOperationException"); delete readOnly; @@ -369,6 +370,26 @@ TEST_F(ByteArrayBufferTest, testGet) << ("Should throw a BufferUnderflowException"); } +//////////////////////////////////////////////////////////////////////////////// +TEST_F(ByteArrayBufferTest, testBufferUnderflowCaughtAsOutOfRange) +{ + testBuffer1->clear(); + while (testBuffer1->hasRemaining()) + { + testBuffer1->get(); + } + bool caughtGeneric = false; + try + { + testBuffer1->get(); + } + catch (std::out_of_range&) + { + caughtGeneric = true; + } + ASSERT_TRUE(caughtGeneric); +} + //////////////////////////////////////////////////////////////////////////////// TEST_F(ByteArrayBufferTest, testGetbyteArray) { @@ -408,8 +429,8 @@ TEST_F(ByteArrayBufferTest, testGetbyteArray2) ASSERT_TRUE(testBuffer1->position() == 0); - ASSERT_THROW(testBuffer1->get(NULL, 0, 0, 1), NullPointerException) - << ("Should throw a NullPointerException"); + ASSERT_THROW(testBuffer1->get(NULL, 0, 0, 1), std::logic_error) + << ("Should throw a std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -441,9 +462,8 @@ TEST_F(ByteArrayBufferTest, testGetWithIndex) ASSERT_TRUE(testBuffer1->get() == testBuffer1->get(i)); } - ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -535,8 +555,8 @@ TEST_F(ByteArrayBufferTest, testPutbyteArray2) ASSERT_TRUE(testBuffer1->position() == 0); ASSERT_THROW(testBuffer1->put(NULL, 0, 2, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw a NullPointerException"); + std::logic_error) + << ("Should throw a std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -571,7 +591,7 @@ TEST_F(ByteArrayBufferTest, testPutByteBuffer) << ("Should throw a ReadOnlyBufferException"); delete readOnly; - ASSERT_THROW(testBuffer1->put(*testBuffer1), IllegalArgumentException) + ASSERT_THROW(testBuffer1->put(*testBuffer1), std::invalid_argument) << ("Should throw a IllegalArgumentException"); ByteBuffer* toBig = testBuffer1->allocate(testBuffer1->capacity() + 1); @@ -618,9 +638,8 @@ TEST_F(ByteArrayBufferTest, testPutIndexed) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -702,8 +721,8 @@ TEST_F(ByteArrayBufferTest, testGetChar2) } ASSERT_THROW(testBuffer1->getChar(testBuffer1->capacity() + 1), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -749,8 +768,8 @@ TEST_F(ByteArrayBufferTest, testPutChar2) ASSERT_TRUE(testBuffer1->get(i) == (char)i); } - ASSERT_THROW(testBuffer1->putChar(i, 'A'), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->putChar(i, 'A'), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -793,8 +812,8 @@ TEST_F(ByteArrayBufferTest, testGetDouble2) ASSERT_TRUE(testBuffer1->getDouble(i) == values[j]); } - ASSERT_THROW(testBuffer1->getDouble(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->getDouble(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -844,8 +863,8 @@ TEST_F(ByteArrayBufferTest, testPutDouble2) Double::doubleToLongBits(99.99 + i)); } - ASSERT_THROW(testBuffer1->putDouble(i, 3.14159), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->putDouble(i, 3.14159), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -888,8 +907,8 @@ TEST_F(ByteArrayBufferTest, testGetFloat2) ASSERT_TRUE(testBuffer1->getFloat(i) == values[j]); } - ASSERT_THROW(testBuffer1->getFloat(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->getFloat(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -939,8 +958,8 @@ TEST_F(ByteArrayBufferTest, testPutFloat2) Float::floatToIntBits(99.99f + (float)i)); } - ASSERT_THROW(testBuffer1->putFloat(i, 3.14159f), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->putFloat(i, 3.14159f), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -983,8 +1002,8 @@ TEST_F(ByteArrayBufferTest, testGetLong2) ASSERT_TRUE(testBuffer1->getLong(i) == values[j]); } - ASSERT_THROW(testBuffer1->getLong(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->getLong(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1032,8 +1051,8 @@ TEST_F(ByteArrayBufferTest, testPutLong2) ASSERT_TRUE(testBuffer1->getLong(i) == (long long)(i + 99)); } - ASSERT_THROW(testBuffer1->putLong(i, 3), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->putLong(i, 3), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1076,8 +1095,8 @@ TEST_F(ByteArrayBufferTest, testGetInt2) ASSERT_TRUE(testBuffer1->getInt(i) == values[j]); } - ASSERT_THROW(testBuffer1->getInt(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->getInt(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1125,8 +1144,8 @@ TEST_F(ByteArrayBufferTest, testPutInt2) ASSERT_TRUE(testBuffer1->getInt(i) == (int)(i + 99)); } - ASSERT_THROW(testBuffer1->putInt(i, 3), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->putInt(i, 3), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1169,8 +1188,8 @@ TEST_F(ByteArrayBufferTest, testGetShort2) ASSERT_TRUE(testBuffer1->getShort(i) == values[j]); } - ASSERT_THROW(testBuffer1->getShort(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->getShort(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1218,13 +1237,13 @@ TEST_F(ByteArrayBufferTest, testPutShort2) ASSERT_TRUE(testBuffer1->getShort(i) == (short)(i + 99)); } - ASSERT_THROW(testBuffer1->putShort(i, 3), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->putShort(i, 3), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// TEST_F(ByteArrayBufferTest, testWrapNullArray) { - ASSERT_THROW(testBuffer1->wrap(NULL, 0, 0, 3), NullPointerException) - << ("Should throw a NullPointerException"); + ASSERT_THROW(testBuffer1->wrap(NULL, 0, 0, 3), std::logic_error) + << ("Should throw a std::logic_error"); } diff --git a/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.cpp b/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.cpp index 08c21b165..c32979d2e 100644 --- a/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.cpp +++ b/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.cpp @@ -15,12 +15,14 @@ * limitations under the License. */ +#include #include #include #include #include #include #include +#include namespace decaf { @@ -37,7 +39,7 @@ using namespace decaf; using namespace decaf::nio; using namespace decaf::internal::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; class CharArrayBufferTest : public ::testing::Test { @@ -107,11 +109,10 @@ class MyCharSequence : public lang::CharSequence { if (index > (int)this->value.length()) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( - __FILE__, - __LINE__, - "MyCharSequence::charAt - index is to big: %d", - index); + throw std::out_of_range( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + + "MyCharSequence::charAt - index is to big: " + + std::to_string(index)); } return this->value.at(index); @@ -121,7 +122,7 @@ class MyCharSequence : public lang::CharSequence { if (start > end) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( + throw ::activemq::exceptions::OutOfRangeException( __FILE__, __LINE__, "CharArrayBuffer::subSequence - start > end"); @@ -129,7 +130,7 @@ class MyCharSequence : public lang::CharSequence if (start > this->length() || end > this->length()) { - throw decaf::lang::exceptions::IndexOutOfBoundsException( + throw ::activemq::exceptions::OutOfRangeException( __FILE__, __LINE__, "CharArrayBuffer::subSequence - Sequence exceed limit"); @@ -208,10 +209,10 @@ TEST_F(CharArrayBufferTest, testReadOnlyArray) ASSERT_TRUE(readOnly != NULL); ASSERT_TRUE(readOnly->isReadOnly() == true); - ASSERT_THROW(readOnly->array(), UnsupportedOperationException) + ASSERT_THROW(readOnly->array(), std::logic_error) << ("Should throw UnsupportedOperationException"); - ASSERT_THROW(readOnly->arrayOffset(), UnsupportedOperationException) + ASSERT_THROW(readOnly->arrayOffset(), std::logic_error) << ("Should throw UnsupportedOperationException"); delete readOnly; @@ -478,44 +479,44 @@ TEST_F(CharArrayBufferTest, testGetbyteArray2) testBuffer1->capacity(), -1, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array, testBuffer1->capacity(), 2, -1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array, testBuffer1->capacity(), 2, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array, testBuffer1->capacity(), Integer::MAX_VALUE, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); - ASSERT_THROW(testBuffer1->get(NULL, 0, 0, 1), NullPointerException) - << ("Should throw a NullPointerException"); + ASSERT_THROW(testBuffer1->get(NULL, 0, 0, 1), std::logic_error) + << ("Should throw a std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -547,12 +548,11 @@ TEST_F(CharArrayBufferTest, testGetWithIndex) ASSERT_TRUE(testBuffer1->get() == testBuffer1->get(i)); } - ASSERT_THROW(testBuffer1->get(-1), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(-1), std::out_of_range) + << ("Should throw a std::out_of_range"); - ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -644,8 +644,8 @@ TEST_F(CharArrayBufferTest, testPutbyteArray2) ASSERT_TRUE(testBuffer1->position() == 0); ASSERT_THROW(testBuffer1->put(NULL, 0, 2, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw a NullPointerException"); + std::logic_error) + << ("Should throw a std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -680,7 +680,7 @@ TEST_F(CharArrayBufferTest, testPutCharBuffer) << ("Should throw a ReadOnlyBufferException"); delete readOnly; - ASSERT_THROW(testBuffer1->put(*testBuffer1), IllegalArgumentException) + ASSERT_THROW(testBuffer1->put(*testBuffer1), std::invalid_argument) << ("Should throw a IllegalArgumentException"); CharBuffer* toBig = testBuffer1->allocate(testBuffer1->capacity() + 1); @@ -727,12 +727,11 @@ TEST_F(CharArrayBufferTest, testPutIndexed) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(-1, 0), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(-1, 0), std::out_of_range) + << ("Should throw a std::out_of_range"); - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -782,8 +781,8 @@ TEST_F(CharArrayBufferTest, testToString) //////////////////////////////////////////////////////////////////////////////// TEST_F(CharArrayBufferTest, testWrapNullArray) { - ASSERT_THROW(testBuffer1->wrap((char*)NULL, 0, 0, 3), NullPointerException) - << ("Should throw a NullPointerException"); + ASSERT_THROW(testBuffer1->wrap((char*)NULL, 0, 0, 3), std::logic_error) + << ("Should throw a std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -796,11 +795,11 @@ TEST_F(CharArrayBufferTest, testCharAt) } ASSERT_THROW(testBuffer1->charAt(testBuffer1->remaining()), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw a std::out_of_range"); - ASSERT_THROW(testBuffer1->charAt(-1), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->charAt(-1), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -814,20 +813,20 @@ TEST_F(CharArrayBufferTest, testSubSequence) { ASSERT_THROW(testBuffer1->subSequence(testBuffer1->length() + 1, testBuffer1->length() + 1), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw a std::out_of_range"); CharSequence* sub1 = testBuffer1->subSequence(testBuffer1->length(), testBuffer1->length()); ASSERT_TRUE(sub1->length() == 0); delete sub1; - ASSERT_THROW(testBuffer1->subSequence(1, 0), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->subSequence(1, 0), std::out_of_range) + << ("Should throw a std::out_of_range"); ASSERT_THROW(testBuffer1->subSequence(1, testBuffer1->length() + 1), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw a std::out_of_range"); CharSequence* sub2 = testBuffer1->subSequence(0, testBuffer1->length()); ASSERT_TRUE(sub2->toString() == testBuffer1->toString()); @@ -873,18 +872,18 @@ TEST_F(CharArrayBufferTest, testPutStringWithArgs) ASSERT_THROW( testBuffer1->put(str, (int)str.length() + 1, (int)str.length() + 2), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw a std::out_of_range"); testBuffer1->put(str, (int)str.length(), (int)str.length()); ASSERT_TRUE(testBuffer1->position() == 0); - ASSERT_THROW(testBuffer1->put(str, 2, 1), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(str, 2, 1), std::out_of_range) + << ("Should throw a std::out_of_range"); ASSERT_THROW(testBuffer1->put(str, 2, (int)str.length() + 1), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw a std::out_of_range"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -1027,14 +1026,14 @@ TEST_F(CharArrayBufferTest, testAppendCharSequenceII_IllegalArgument) cb->append(&cs, 0, 0); cb->append(&cs, 2, 2); - ASSERT_THROW(cb->append(&cs, 3, 2), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(cb->append(&cs, 3, 2), std::out_of_range) + << ("Should throw a std::out_of_range"); - ASSERT_THROW(cb->append(&cs, 3, 0), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(cb->append(&cs, 3, 0), std::out_of_range) + << ("Should throw a std::out_of_range"); - ASSERT_THROW(cb->append(&cs, 3, 110), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(cb->append(&cs, 3, 110), std::out_of_range) + << ("Should throw a std::out_of_range"); delete cb; } @@ -1060,9 +1059,9 @@ TEST_F(CharArrayBufferTest, testReadCharBuffer) // return -1 when nothing to read ASSERT_TRUE(-1 == source->read(target)); - // NullPointerException - ASSERT_THROW(source->read(NULL), NullPointerException) - << ("Should throw a NullPointerException"); + // std::logic_error + ASSERT_THROW(source->read(NULL), std::logic_error) + << ("Should throw a std::logic_error"); delete source; delete target; @@ -1075,7 +1074,7 @@ TEST_F(CharArrayBufferTest, testReadReadOnly) CharBuffer::wrap(testData1, testData1Size, 0, testData1Size); CharBuffer* target = testBuffer1->asReadOnlyBuffer(); - // NullPointerException + // std::logic_error ASSERT_THROW(source->read(target), ReadOnlyBufferException) << ("Should throw a ReadOnlyBufferException"); @@ -1110,7 +1109,7 @@ TEST_F(CharArrayBufferTest, testReadSelf) CharBuffer* source = CharBuffer::wrap(testData1, testData1Size, 0, testData1Size); - ASSERT_THROW(source->read(source), IllegalArgumentException) + ASSERT_THROW(source->read(source), std::invalid_argument) << ("Should throw a IllegalArgumentException"); delete source; diff --git a/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.cpp b/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.cpp index 12f89a6c7..c8831ee5c 100644 --- a/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.cpp +++ b/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.cpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace decaf { @@ -36,7 +37,7 @@ using namespace decaf; using namespace decaf::nio; using namespace decaf::internal::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; class DoubleArrayBufferTest : public ::testing::Test { @@ -245,10 +246,10 @@ TEST_F(DoubleArrayBufferTest, testReadOnlyArray) ASSERT_TRUE(readOnly != NULL); ASSERT_TRUE(readOnly->isReadOnly() == true); - ASSERT_THROW(readOnly->array(), UnsupportedOperationException) + ASSERT_THROW(readOnly->array(), std::logic_error) << ("Should throw UnsupportedOperationException"); - ASSERT_THROW(readOnly->arrayOffset(), UnsupportedOperationException) + ASSERT_THROW(readOnly->arrayOffset(), std::logic_error) << ("Should throw UnsupportedOperationException"); delete readOnly; @@ -481,41 +482,41 @@ TEST_F(DoubleArrayBufferTest, testGetDoubleArray2) testBuffer1->capacity(), -1, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), 2, -1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), 2, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -542,12 +543,11 @@ TEST_F(DoubleArrayBufferTest, testGet2) ASSERT_TRUE(testBuffer1->get() == testBuffer1->get(i)); } - ASSERT_THROW(testBuffer1->get(-1), IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(-1), std::out_of_range) + << ("Should throw std::out_of_range"); - ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), std::out_of_range) + << ("Should throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -620,41 +620,41 @@ TEST_F(DoubleArrayBufferTest, testPutDoubleArray2) testBuffer1->capacity(), -1, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), 2, -1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), 2, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -677,7 +677,7 @@ TEST_F(DoubleArrayBufferTest, testPutDoubleBuffer) DoubleBuffer* other = DoubleBuffer::allocate(testBuffer1->capacity()); DoubleBuffer* other1 = DoubleBuffer::allocate(testBuffer1->capacity() + 1); - ASSERT_THROW(testBuffer1->put(*testBuffer1), IllegalArgumentException) + ASSERT_THROW(testBuffer1->put(*testBuffer1), std::invalid_argument) << ("Should throw IllegalArgumentException"); ASSERT_THROW(testBuffer1->put(*other1), BufferOverflowException) @@ -710,12 +710,11 @@ TEST_F(DoubleArrayBufferTest, testGetWithIndex) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(-1, 0), IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(-1, 0), std::out_of_range) + << ("Should throw std::out_of_range"); - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -737,9 +736,8 @@ TEST_F(DoubleArrayBufferTest, testPutIndexed) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.cpp b/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.cpp index 7d9f61f47..cd3fecd66 100644 --- a/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.cpp +++ b/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.cpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace decaf { @@ -36,7 +37,7 @@ using namespace decaf; using namespace decaf::nio; using namespace decaf::internal::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; class FloatArrayBufferTest : public ::testing::Test { @@ -245,10 +246,10 @@ TEST_F(FloatArrayBufferTest, testReadOnlyArray) ASSERT_TRUE(readOnly != NULL); ASSERT_TRUE(readOnly->isReadOnly() == true); - ASSERT_THROW(readOnly->array(), UnsupportedOperationException) + ASSERT_THROW(readOnly->array(), std::logic_error) << ("Should throw UnsupportedOperationException"); - ASSERT_THROW(readOnly->arrayOffset(), UnsupportedOperationException) + ASSERT_THROW(readOnly->arrayOffset(), std::logic_error) << ("Should throw UnsupportedOperationException"); delete readOnly; @@ -481,41 +482,41 @@ TEST_F(FloatArrayBufferTest, testGetFloatArray2) testBuffer1->capacity(), -1, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), 2, -1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), 2, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -542,12 +543,11 @@ TEST_F(FloatArrayBufferTest, testGet2) ASSERT_TRUE(testBuffer1->get() == testBuffer1->get(i)); } - ASSERT_THROW(testBuffer1->get(-1), IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(-1), std::out_of_range) + << ("Should throw std::out_of_range"); - ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), std::out_of_range) + << ("Should throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -620,41 +620,41 @@ TEST_F(FloatArrayBufferTest, testPutFloatArray2) testBuffer1->capacity(), -1, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), 2, -1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), 2, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -677,7 +677,7 @@ TEST_F(FloatArrayBufferTest, testPutFloatBuffer) FloatBuffer* other = FloatBuffer::allocate(testBuffer1->capacity()); FloatBuffer* other1 = FloatBuffer::allocate(testBuffer1->capacity() + 1); - ASSERT_THROW(testBuffer1->put(*testBuffer1), IllegalArgumentException) + ASSERT_THROW(testBuffer1->put(*testBuffer1), std::invalid_argument) << ("Should throw IllegalArgumentException"); ASSERT_THROW(testBuffer1->put(*other1), BufferOverflowException) @@ -710,12 +710,11 @@ TEST_F(FloatArrayBufferTest, testGetWithIndex) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(-1, 0), IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(-1, 0), std::out_of_range) + << ("Should throw std::out_of_range"); - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -737,12 +736,11 @@ TEST_F(FloatArrayBufferTest, testPutIndexed) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(-1, 0), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(-1, 0), std::out_of_range) + << ("Should throw a std::out_of_range"); - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/internal/nio/IntArrayBufferTest.cpp b/activemq-cpp/src/test/decaf/internal/nio/IntArrayBufferTest.cpp index adab41a6f..23e9df7fa 100644 --- a/activemq-cpp/src/test/decaf/internal/nio/IntArrayBufferTest.cpp +++ b/activemq-cpp/src/test/decaf/internal/nio/IntArrayBufferTest.cpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace decaf { @@ -36,7 +37,7 @@ using namespace decaf; using namespace decaf::nio; using namespace decaf::internal::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; class IntArrayBufferTest : public ::testing::Test { @@ -245,10 +246,10 @@ TEST_F(IntArrayBufferTest, testReadOnlyArray) ASSERT_TRUE(readOnly != NULL); ASSERT_TRUE(readOnly->isReadOnly() == true); - ASSERT_THROW(readOnly->array(), UnsupportedOperationException) + ASSERT_THROW(readOnly->array(), std::logic_error) << ("Should throw UnsupportedOperationException"); - ASSERT_THROW(readOnly->arrayOffset(), UnsupportedOperationException) + ASSERT_THROW(readOnly->arrayOffset(), std::logic_error) << ("Should throw UnsupportedOperationException"); delete readOnly; @@ -481,41 +482,41 @@ TEST_F(IntArrayBufferTest, testGetIntArray2) testBuffer1->capacity(), -1, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), 2, -1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), 2, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -542,12 +543,11 @@ TEST_F(IntArrayBufferTest, testGet2) ASSERT_TRUE(testBuffer1->get() == testBuffer1->get(i)); } - ASSERT_THROW(testBuffer1->get(-1), IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(-1), std::out_of_range) + << ("Should throw std::out_of_range"); - ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), std::out_of_range) + << ("Should throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -620,41 +620,41 @@ TEST_F(IntArrayBufferTest, testPutIntArray2) testBuffer1->capacity(), -1, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), 2, -1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), 2, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -677,7 +677,7 @@ TEST_F(IntArrayBufferTest, testPutIntBuffer) IntBuffer* other = IntBuffer::allocate(testBuffer1->capacity()); IntBuffer* other1 = IntBuffer::allocate(testBuffer1->capacity() + 1); - ASSERT_THROW(testBuffer1->put(*testBuffer1), IllegalArgumentException) + ASSERT_THROW(testBuffer1->put(*testBuffer1), std::invalid_argument) << ("Should throw IllegalArgumentException"); ASSERT_THROW(testBuffer1->put(*other1), BufferOverflowException) @@ -710,12 +710,11 @@ TEST_F(IntArrayBufferTest, testGetWithIndex) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(-1, 0), IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(-1, 0), std::out_of_range) + << ("Should throw std::out_of_range"); - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -737,12 +736,11 @@ TEST_F(IntArrayBufferTest, testPutIndexed) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(-1, 0), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(-1, 0), std::out_of_range) + << ("Should throw a std::out_of_range"); - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/internal/nio/LongArrayBufferTest.cpp b/activemq-cpp/src/test/decaf/internal/nio/LongArrayBufferTest.cpp index bc8603f5c..976cff588 100644 --- a/activemq-cpp/src/test/decaf/internal/nio/LongArrayBufferTest.cpp +++ b/activemq-cpp/src/test/decaf/internal/nio/LongArrayBufferTest.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace decaf { @@ -37,7 +38,7 @@ using namespace decaf; using namespace decaf::nio; using namespace decaf::internal::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; class LongArrayBufferTest : public ::testing::Test { @@ -246,10 +247,10 @@ TEST_F(LongArrayBufferTest, testReadOnlyArray) ASSERT_TRUE(readOnly != NULL); ASSERT_TRUE(readOnly->isReadOnly() == true); - ASSERT_THROW(readOnly->array(), UnsupportedOperationException) + ASSERT_THROW(readOnly->array(), std::logic_error) << ("Should throw UnsupportedOperationException"); - ASSERT_THROW(readOnly->arrayOffset(), UnsupportedOperationException) + ASSERT_THROW(readOnly->arrayOffset(), std::logic_error) << ("Should throw UnsupportedOperationException"); delete readOnly; @@ -482,41 +483,41 @@ TEST_F(LongArrayBufferTest, testGetLongArray2) testBuffer1->capacity(), -1, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), 2, -1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), 2, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -543,12 +544,11 @@ TEST_F(LongArrayBufferTest, testGet2) ASSERT_TRUE(testBuffer1->get() == testBuffer1->get(i)); } - ASSERT_THROW(testBuffer1->get(-1), IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(-1), std::out_of_range) + << ("Should throw std::out_of_range"); - ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), std::out_of_range) + << ("Should throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -621,41 +621,41 @@ TEST_F(LongArrayBufferTest, testPutLongArray2) testBuffer1->capacity(), -1, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), 2, -1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), 2, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -678,7 +678,7 @@ TEST_F(LongArrayBufferTest, testPutLongBuffer) LongBuffer* other = LongBuffer::allocate(testBuffer1->capacity()); LongBuffer* other1 = LongBuffer::allocate(testBuffer1->capacity() + 1); - ASSERT_THROW(testBuffer1->put(*testBuffer1), IllegalArgumentException) + ASSERT_THROW(testBuffer1->put(*testBuffer1), std::invalid_argument) << ("Should throw IllegalArgumentException"); ASSERT_THROW(testBuffer1->put(*other1), BufferOverflowException) @@ -711,12 +711,11 @@ TEST_F(LongArrayBufferTest, testGetWithIndex) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(-1, 0), IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(-1, 0), std::out_of_range) + << ("Should throw std::out_of_range"); - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -738,12 +737,11 @@ TEST_F(LongArrayBufferTest, testPutIndexed) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(-1, 0), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(-1, 0), std::out_of_range) + << ("Should throw a std::out_of_range"); - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/internal/nio/ShortArrayBufferTest.cpp b/activemq-cpp/src/test/decaf/internal/nio/ShortArrayBufferTest.cpp index 051528d2e..734b88d90 100644 --- a/activemq-cpp/src/test/decaf/internal/nio/ShortArrayBufferTest.cpp +++ b/activemq-cpp/src/test/decaf/internal/nio/ShortArrayBufferTest.cpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace decaf { @@ -36,7 +37,7 @@ using namespace decaf; using namespace decaf::nio; using namespace decaf::internal::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; class ShortArrayBufferTest : public ::testing::Test { @@ -245,10 +246,10 @@ TEST_F(ShortArrayBufferTest, testReadOnlyArray) ASSERT_TRUE(readOnly != NULL); ASSERT_TRUE(readOnly->isReadOnly() == true); - ASSERT_THROW(readOnly->array(), UnsupportedOperationException) + ASSERT_THROW(readOnly->array(), std::logic_error) << ("Should throw UnsupportedOperationException"); - ASSERT_THROW(readOnly->arrayOffset(), UnsupportedOperationException) + ASSERT_THROW(readOnly->arrayOffset(), std::logic_error) << ("Should throw UnsupportedOperationException"); delete readOnly; @@ -481,41 +482,41 @@ TEST_F(ShortArrayBufferTest, testGetShortArray2) testBuffer1->capacity(), -1, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), 2, -1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->get(array1, testBuffer1->capacity(), 2, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->get(NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -542,12 +543,11 @@ TEST_F(ShortArrayBufferTest, testGet2) ASSERT_TRUE(testBuffer1->get() == testBuffer1->get(i)); } - ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(testBuffer1->limit()), std::out_of_range) + << ("Should throw std::out_of_range"); - ASSERT_THROW(testBuffer1->get(-1), IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->get(-1), std::out_of_range) + << ("Should throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -620,41 +620,41 @@ TEST_F(ShortArrayBufferTest, testPutShortArray2) testBuffer1->capacity(), -1, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), 2, -1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW(testBuffer1->put(array1, testBuffer1->capacity(), 2, testBuffer1->capacity()), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw std::out_of_range"); ASSERT_THROW( testBuffer1->put(NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE), - NullPointerException) - << ("Should throw NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); ASSERT_TRUE(testBuffer1->position() == 0); @@ -677,7 +677,7 @@ TEST_F(ShortArrayBufferTest, testPutShortBuffer) ShortBuffer* other = ShortBuffer::allocate(testBuffer1->capacity()); ShortBuffer* other1 = ShortBuffer::allocate(testBuffer1->capacity() + 1); - ASSERT_THROW(testBuffer1->put(*testBuffer1), IllegalArgumentException) + ASSERT_THROW(testBuffer1->put(*testBuffer1), std::invalid_argument) << ("Should throw IllegalArgumentException"); ASSERT_THROW(testBuffer1->put(*other1), BufferOverflowException) @@ -710,12 +710,11 @@ TEST_F(ShortArrayBufferTest, testGetWithIndex) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(-1, 0), IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(-1, 0), std::out_of_range) + << ("Should throw std::out_of_range"); - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -737,12 +736,11 @@ TEST_F(ShortArrayBufferTest, testPutIndexed) ASSERT_TRUE(&ret == testBuffer1); } - ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(testBuffer1->limit(), 0), std::out_of_range) + << ("Should throw a std::out_of_range"); - ASSERT_THROW(testBuffer1->put(-1, 0), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1->put(-1, 0), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/internal/util/ByteArrayAdapterTest.cpp b/activemq-cpp/src/test/decaf/internal/util/ByteArrayAdapterTest.cpp index 87b5f41b1..81a3b730f 100644 --- a/activemq-cpp/src/test/decaf/internal/util/ByteArrayAdapterTest.cpp +++ b/activemq-cpp/src/test/decaf/internal/util/ByteArrayAdapterTest.cpp @@ -17,6 +17,8 @@ #include +#include + #include #include #include @@ -27,7 +29,7 @@ using namespace decaf::internal; using namespace decaf::internal::util; using namespace decaf::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using activemq::exceptions::BufferUnderflowException; class ByteArrayAdapterTest : public ::testing::Test { @@ -263,8 +265,8 @@ TEST_F(ByteArrayAdapterTest, testReadExceptions) ByteArrayAdapter array(data, 256, true); - ASSERT_THROW(array.read(NULL, 1, 0, 500), NullPointerException) - << ("Should Throw NullPointerException"); + ASSERT_THROW(array.read(NULL, 1, 0, 500), std::logic_error) + << ("Should Throw std::logic_error"); unsigned char result[5000]; ByteArrayAdapter array2(256); @@ -283,8 +285,8 @@ TEST_F(ByteArrayAdapterTest, testWriteExceptions) } ByteArrayAdapter array(data, 256, true); - ASSERT_THROW(array.write(NULL, 1, 0, 500), NullPointerException) - << ("Should Throw NullPointerException"); + ASSERT_THROW(array.write(NULL, 1, 0, 500), std::logic_error) + << ("Should Throw std::logic_error"); unsigned char result[5000]; ByteArrayAdapter array2(256); @@ -303,8 +305,8 @@ TEST_F(ByteArrayAdapterTest, testOperatorsExceptions) } ByteArrayAdapter array(data, 256, true); - ASSERT_THROW(array[9999], IndexOutOfBoundsException) - << ("Should Throw IndexOutOfBoundsException"); + ASSERT_THROW(array[9999], std::out_of_range) + << ("Should Throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -320,8 +322,8 @@ TEST_F(ByteArrayAdapterTest, testPut) ASSERT_TRUE(testBuffer1.get(i) == (unsigned char)(i + 99)); } - ASSERT_THROW(testBuffer1.put(i, 3), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.put(i, 3), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -337,8 +339,8 @@ TEST_F(ByteArrayAdapterTest, testPutChar) ASSERT_TRUE(testBuffer1.getChar(i) == (char)(i + 99)); } - ASSERT_THROW(testBuffer1.putChar(i, 3), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.putChar(i, 3), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -353,8 +355,8 @@ TEST_F(ByteArrayAdapterTest, testPutLong) ASSERT_TRUE(testBuffer1.getLong(i) == (long long)(i + 99)); } - ASSERT_THROW(testBuffer1.putLong(i, 3), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.putLong(i, 3), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -369,8 +371,8 @@ TEST_F(ByteArrayAdapterTest, testPutInt) ASSERT_TRUE(testBuffer1.getInt(i) == (int)(i + 99)); } - ASSERT_THROW(testBuffer1.putInt(i, 3), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.putInt(i, 3), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -385,8 +387,8 @@ TEST_F(ByteArrayAdapterTest, testPutShort) ASSERT_TRUE(testBuffer1.getShort(i) == (short)(i + 99)); } - ASSERT_THROW(testBuffer1.putShort(i, 3), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.putShort(i, 3), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -402,8 +404,8 @@ TEST_F(ByteArrayAdapterTest, testPutDouble) Double::doubleToLongBits((double)(i + 99.025))); } - ASSERT_THROW(testBuffer1.putDouble(i, 3), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.putDouble(i, 3), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -419,8 +421,8 @@ TEST_F(ByteArrayAdapterTest, testPutFloat) Float::floatToIntBits((float)(i + 99.025))); } - ASSERT_THROW(testBuffer1.putFloat(i, 3), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.putFloat(i, 3), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -443,8 +445,8 @@ TEST_F(ByteArrayAdapterTest, testGet) ASSERT_TRUE(testBuffer1.get(i) == values[j]); } - ASSERT_THROW(testBuffer1.get(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.get(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -467,8 +469,8 @@ TEST_F(ByteArrayAdapterTest, testGetChar) ASSERT_TRUE(testBuffer1.getChar(i) == values[j]); } - ASSERT_THROW(testBuffer1.getChar(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.getChar(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -491,8 +493,8 @@ TEST_F(ByteArrayAdapterTest, testGetShort) ASSERT_TRUE(testBuffer1.getShort(i) == values[j]); } - ASSERT_THROW(testBuffer1.getShort(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.getShort(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -515,8 +517,8 @@ TEST_F(ByteArrayAdapterTest, testGetInt) ASSERT_TRUE(testBuffer1.getInt(i) == values[j]); } - ASSERT_THROW(testBuffer1.getInt(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.getInt(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -539,8 +541,8 @@ TEST_F(ByteArrayAdapterTest, testGetLong) ASSERT_TRUE(testBuffer1.getLong(i) == values[j]); } - ASSERT_THROW(testBuffer1.getLong(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.getLong(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -564,8 +566,8 @@ TEST_F(ByteArrayAdapterTest, testGetFloat) Float::floatToIntBits(values[j])); } - ASSERT_THROW(testBuffer1.getFloat(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.getFloat(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -589,6 +591,6 @@ TEST_F(ByteArrayAdapterTest, testGetDouble) Double::doubleToLongBits(values[j])); } - ASSERT_THROW(testBuffer1.getDouble(i), IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + ASSERT_THROW(testBuffer1.getDouble(i), std::out_of_range) + << ("Should throw a std::out_of_range"); } diff --git a/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.cpp b/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.cpp index 0758aa42b..e60086ba6 100644 --- a/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #ifdef HAVE_STRING_H @@ -29,12 +28,12 @@ #endif #ifdef HAVE_STRINGS_H #include +#include #endif using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::util; @@ -60,12 +59,11 @@ const std::string BufferedInputStreamTest::testString = "Test_java_io_RandomAccessFile\nTest_java_io_SyncFailedException\nTest_" "java_lang_AbstractMethodError\n" "Test_java_lang_ArithmeticException\nTest_java_lang_" - "ArrayIndexOutOfBoundsException\n" + "ArrayIndexOutOfBoundsMarker\n" "Test_java_lang_ArrayStoreException\nTest_java_lang_Boolean\nTest_java_" "lang_Byte\n" "Test_java_lang_Character\nTest_java_lang_Class\nTest_java_lang_" - "ClassCastException\n" - "Test_java_lang_ClassCircularityError\nTest_java_lang_ClassFormatError\n" + "ClassCircularityError\nTest_java_lang_ClassFormatError\n" "Test_java_lang_ClassLoader\nTest_java_lang_ClassNotFoundException\n" "Test_java_lang_CloneNotSupportedException\nTest_java_lang_Double\nTest_" "java_lang_Error\n" @@ -73,21 +71,20 @@ const std::string BufferedInputStreamTest::testString = "ExceptionInInitializerError\nTest_java_lang_Float\n" "Test_java_lang_IllegalAccessError\nTest_java_lang_IllegalAccessException\n" "Test_java_lang_IllegalArgumentException\nTest_java_lang_" - "IllegalMonitorStateException\n" + "" "Test_java_lang_IllegalThreadStateException\nTest_java_lang_" "IncompatibleClassChangeError\n" "Test_java_lang_IndexOutOfBoundsException\nTest_java_lang_" "InstantiationError\n" "Test_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_" "lang_InternalError\n" - "Test_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_" + "Test_java_lang_RuntimeError\nTest_java_lang_LinkageError\nTest_" "java_lang_Long\n" "Test_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_" "lang_NoClassDefFoundError\n" "Test_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\n" "Test_java_lang_NullPointerException\nTest_java_lang_Number\nTest_java_" - "lang_NumberFormatException\n" - "Test_java_lang_Object\nTest_java_lang_OutOfMemoryError\nTest_java_lang_" + "lang_Object\nTest_java_lang_OutOfMemoryError\nTest_java_lang_" "RuntimeException\n" "Test_java_lang_SecurityManager\nTest_java_lang_Short\nTest_java_lang_" "StackOverflowError\n" @@ -426,11 +423,11 @@ TEST_F(BufferedInputStreamTest, testReadException) BufferedInputStream bis(NULL); - ASSERT_THROW(bis.read(NULL, 1, 0, 1), NullPointerException) - << ("should throw NullPointerException"); + ASSERT_THROW(bis.read(NULL, 1, 0, 1), std::logic_error) + << ("should throw std::logic_error"); - ASSERT_THROW(bis.read(array, 0, 1, 1), IndexOutOfBoundsException) - << ("should throw IndexOutOfBoundsException"); + ASSERT_THROW(bis.read(array, 0, 1, 1), std::out_of_range) + << ("should throw std::out_of_range"); bis.close(); @@ -539,11 +536,17 @@ TEST_F(BufferedInputStreamTest, testMarkI) unsigned char buf1[100]; unsigned char buf2[100]; + memset(buf1, 0, sizeof(buf1)); + memset(buf2, 0, sizeof(buf2)); + is.skip(3000); is.mark(1000); - is.read(buf1, 100); + int numRead1 = is.read(buf1, 100); + ASSERT_GT(numRead1, 0); is.reset(); - is.read(buf2, 100); + int numRead2 = is.read(buf2, 100); + ASSERT_EQ(numRead1, numRead2); + is.reset(); ASSERT_EQ(std::string(buf1, buf1 + 100), std::string(buf2, buf2 + 100)) diff --git a/activemq-cpp/src/test/decaf/io/BufferedOutputStreamTest.cpp b/activemq-cpp/src/test/decaf/io/BufferedOutputStreamTest.cpp index 7dd597040..5a0e23f1c 100644 --- a/activemq-cpp/src/test/decaf/io/BufferedOutputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/io/BufferedOutputStreamTest.cpp @@ -21,11 +21,11 @@ #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::util; @@ -55,10 +55,9 @@ class BufferedOutputStreamTest : public ::testing::Test "RandomAccessFile\nTest_decaf_io_SyncFailedException\nTest_decaf_" "lang_AbstractMethodError\nTest_decaf_lang_" "ArithmeticException\nTest_decaf_lang_" - "ArrayIndexOutOfBoundsException\nTest_decaf_lang_" "ArrayStoreException\nTest_decaf_lang_Boolean\nTest_decaf_lang_" "Byte\nTest_decaf_lang_Character\nTest_decaf_lang_Class\nTest_" - "decaf_lang_ClassCastException\nTest_decaf_lang_" + "decaf_lang_" "ClassCircularityError\nTest_decaf_lang_ClassFormatError\nTest_" "decaf_lang_ClassLoader\nTest_decaf_lang_" "ClassNotFoundException\nTest_decaf_lang_" @@ -68,19 +67,19 @@ class BufferedOutputStreamTest : public ::testing::Test "lang_IllegalAccessError\nTest_decaf_lang_" "IllegalAccessException\nTest_decaf_lang_" "IllegalArgumentException\nTest_decaf_lang_" - "IllegalMonitorStateException\nTest_decaf_lang_" + "" "IllegalThreadStateException\nTest_decaf_lang_" "IncompatibleClassChangeError\nTest_decaf_lang_" - "IndexOutOfBoundsException\nTest_decaf_lang_" + "std::out_of_range\nTest_decaf_lang_" "InstantiationError\nTest_decaf_lang_InstantiationException\nTest_" "decaf_lang_Integer\nTest_decaf_lang_InternalError\nTest_decaf_" - "lang_InterruptedException\nTest_decaf_lang_LinkageError\nTest_" + "lang_RuntimeError\nTest_decaf_lang_LinkageError\nTest_" "decaf_lang_Long\nTest_decaf_lang_Math\nTest_decaf_lang_" - "NegativeArraySizeException\nTest_decaf_lang_" + "std::runtime_error\nTest_decaf_lang_" "NoClassDefFoundError\nTest_decaf_lang_NoSuchFieldError\nTest_" "decaf_lang_NoSuchMethodError\nTest_decaf_lang_" "NullPointerException\nTest_decaf_lang_Number\nTest_decaf_lang_" - "NumberFormatException\nTest_decaf_lang_Object\nTest_decaf_lang_" + "Object\nTest_decaf_lang_" "OutOfMemoryError\nTest_decaf_lang_RuntimeException\nTest_decaf_" "lang_SecurityManager\nTest_decaf_lang_Short\nTest_decaf_lang_" "StackOverflowError\nTest_decaf_lang_String\nTest_decaf_lang_" @@ -259,8 +258,8 @@ TEST_F(BufferedOutputStreamTest, testWriteException) unsigned char* nullByteArray = NULL; unsigned char byteArray[10]; - ASSERT_THROW(bos.write(nullByteArray, 0, 0, 1), NullPointerException) - << ("should throw NullPointerException"); + ASSERT_THROW(bos.write(nullByteArray, 0, 0, 1), std::logic_error) + << ("should throw std::logic_error"); bos.write(byteArray, 10, 0, 0); bos.write(byteArray, 10, 0, 1); @@ -278,10 +277,10 @@ TEST_F(BufferedOutputStreamTest, testWriteNullStreamNullArray) unsigned char* nullByteArray = NULL; ASSERT_THROW(bos.write(nullByteArray, 0, 0, 1), IOException) - << ("should throw NullPointerException"); + << ("should throw std::logic_error"); ASSERT_NO_THROW(bos.write(nullByteArray, 0, 0, 0)) - << ("should not throw NullPointerException"); + << ("should not throw std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -294,7 +293,7 @@ TEST_F(BufferedOutputStreamTest, testWriteNullStreamNullArraySize) << ("should throw IOException"); ASSERT_NO_THROW(bos.write(nullByteArray, 0, 0, 0)) - << ("should not throw NullPointerException"); + << ("should not throw std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -322,10 +321,10 @@ TEST_F(BufferedOutputStreamTest, testWriteNullStreamSize) bos.write(byteArray, 0, 0, 0); ASSERT_THROW(bos.write(byteArray, 10, 0, 2), IOException) - << ("should throw NullPointerException"); + << ("should throw std::logic_error"); ASSERT_THROW(bos.write(byteArray, 10, 0, 10), IOException) - << ("should throw NullPointerException"); + << ("should throw std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/io/ByteArrayOutputStreamTest.cpp b/activemq-cpp/src/test/decaf/io/ByteArrayOutputStreamTest.cpp index dc83e46e1..4ad058c0c 100644 --- a/activemq-cpp/src/test/decaf/io/ByteArrayOutputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/io/ByteArrayOutputStreamTest.cpp @@ -58,10 +58,9 @@ class ByteArrayOutputStreamTest : public ::testing::Test "RandomAccessFile\nTest_decaf_io_SyncFailedException\nTest_decaf_" "lang_AbstractMethodError\nTest_decaf_lang_" "ArithmeticException\nTest_decaf_lang_" - "ArrayIndexOutOfBoundsException\nTest_decaf_lang_" "ArrayStoreException\nTest_decaf_lang_Boolean\nTest_decaf_lang_" "Byte\nTest_decaf_lang_Character\nTest_decaf_lang_Class\nTest_" - "decaf_lang_ClassCastException\nTest_decaf_lang_" + "decaf_lang_" "ClassCircularityError\nTest_decaf_lang_ClassFormatError\nTest_" "decaf_lang_ClassLoader\nTest_decaf_lang_" "ClassNotFoundException\nTest_decaf_lang_" @@ -71,19 +70,19 @@ class ByteArrayOutputStreamTest : public ::testing::Test "lang_IllegalAccessError\nTest_decaf_lang_" "IllegalAccessException\nTest_decaf_lang_" "IllegalArgumentException\nTest_decaf_lang_" - "IllegalMonitorStateException\nTest_decaf_lang_" + "" "IllegalThreadStateException\nTest_decaf_lang_" "IncompatibleClassChangeError\nTest_decaf_lang_" - "IndexOutOfBoundsException\nTest_decaf_lang_" + "std::out_of_range\nTest_decaf_lang_" "InstantiationError\nTest_decaf_lang_InstantiationException\nTest_" "decaf_lang_Integer\nTest_decaf_lang_InternalError\nTest_decaf_" - "lang_InterruptedException\nTest_decaf_lang_LinkageError\nTest_" + "lang_RuntimeError\nTest_decaf_lang_LinkageError\nTest_" "decaf_lang_Long\nTest_decaf_lang_Math\nTest_decaf_lang_" - "NegativeArraySizeException\nTest_decaf_lang_" + "std::runtime_error\nTest_decaf_lang_" "NoClassDefFoundError\nTest_decaf_lang_NoSuchFieldError\nTest_" "decaf_lang_NoSuchMethodError\nTest_decaf_lang_" "NullPointerException\nTest_decaf_lang_Number\nTest_decaf_lang_" - "NumberFormatException\nTest_decaf_lang_Object\nTest_decaf_lang_" + "Object\nTest_decaf_lang_" "OutOfMemoryError\nTest_decaf_lang_RuntimeException\nTest_decaf_" "lang_SecurityManager\nTest_decaf_lang_Short\nTest_decaf_lang_" "StackOverflowError\nTest_decaf_lang_String\nTest_decaf_lang_" diff --git a/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp b/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp index 2241a9c0b..b4d3859f0 100644 --- a/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp @@ -33,12 +33,12 @@ #endif #ifdef HAVE_STRINGS_H #include +#include #endif using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::util; @@ -78,10 +78,9 @@ class DataInputStreamTest : public ::testing::Test "RandomAccessFile\nTest_decaf_io_SyncFailedException\nTest_decaf_" "lang_AbstractMethodError\nTest_decaf_lang_" "ArithmeticException\nTest_decaf_lang_" - "ArrayIndexOutOfBoundsException\nTest_decaf_lang_" "ArrayStoreException\nTest_decaf_lang_Boolean\nTest_decaf_lang_" "Byte\nTest_decaf_lang_Character\nTest_decaf_lang_Class\nTest_" - "decaf_lang_ClassCastException\nTest_decaf_lang_" + "decaf_lang_" "ClassCircularityError\nTest_decaf_lang_ClassFormatError\nTest_" "decaf_lang_ClassLoader\nTest_decaf_lang_" "ClassNotFoundException\nTest_decaf_lang_" @@ -91,19 +90,19 @@ class DataInputStreamTest : public ::testing::Test "lang_IllegalAccessError\nTest_decaf_lang_" "IllegalAccessException\nTest_decaf_lang_" "IllegalArgumentException\nTest_decaf_lang_" - "IllegalMonitorStateException\nTest_decaf_lang_" + "" "IllegalThreadStateException\nTest_decaf_lang_" "IncompatibleClassChangeError\nTest_decaf_lang_" - "IndexOutOfBoundsException\nTest_decaf_lang_" + "std::out_of_range\nTest_decaf_lang_" "InstantiationError\nTest_decaf_lang_InstantiationException\nTest_" "decaf_lang_Integer\nTest_decaf_lang_InternalError\nTest_decaf_" - "lang_InterruptedException\nTest_decaf_lang_LinkageError\nTest_" + "lang_RuntimeError\nTest_decaf_lang_LinkageError\nTest_" "decaf_lang_Long\nTest_decaf_lang_Math\nTest_decaf_lang_" - "NegativeArraySizeException\nTest_decaf_lang_" + "std::runtime_error\nTest_decaf_lang_" "NoClassDefFoundError\nTest_decaf_lang_NoSuchFieldError\nTest_" "decaf_lang_NoSuchMethodError\nTest_decaf_lang_" "NullPointerException\nTest_decaf_lang_Number\nTest_decaf_lang_" - "NumberFormatException\nTest_decaf_lang_Object\nTest_decaf_lang_" + "Object\nTest_decaf_lang_" "OutOfMemoryError\nTest_decaf_lang_RuntimeException\nTest_decaf_" "lang_SecurityManager\nTest_decaf_lang_Short\nTest_decaf_lang_" "StackOverflowError\nTest_decaf_lang_String\nTest_decaf_lang_" @@ -329,8 +328,8 @@ TEST_F(DataInputStreamTest, test_readFully1) ASSERT_TRUE(expected == testData) << ("Incorrect data read"); - ASSERT_THROW(is->readFully(&result[0], -1), IndexOutOfBoundsException) - << ("should throw IndexOutOfBoundsException"); + ASSERT_THROW(is->readFully(&result[0], -1), std::out_of_range) + << ("should throw std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -351,34 +350,34 @@ TEST_F(DataInputStreamTest, test_readFully2) ASSERT_TRUE(expected == testData) << ("Incorrect data read"); ASSERT_THROW(is->readFully(&temp[0], (int)temp.size(), -1, -1), - IndexOutOfBoundsException) - << ("should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("should throw std::out_of_range"); ASSERT_THROW(is->readFully(&temp[0], (int)temp.size(), 0, -1), - IndexOutOfBoundsException) - << ("should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("should throw std::out_of_range"); ASSERT_THROW(is->readFully(&temp[0], (int)temp.size(), 1, -1), - IndexOutOfBoundsException) - << ("should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("should throw std::out_of_range"); is->readFully(&temp[0], (int)temp.size(), -1, 0); is->readFully(&temp[0], (int)temp.size(), 0, 0); is->readFully(&temp[0], (int)temp.size(), 1, 0); ASSERT_THROW(is->readFully(&temp[0], (int)temp.size(), -1, 1), - IndexOutOfBoundsException) - << ("should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("should throw std::out_of_range"); ASSERT_THROW( is->readFully(&temp[0], (int)temp.size(), 0, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("should throw std::out_of_range"); ASSERT_THROW( is->readFully(&temp[0], (int)temp.size(), 1, Integer::MAX_VALUE), - IndexOutOfBoundsException) - << ("should throw IndexOutOfBoundsException"); + std::out_of_range) + << ("should throw std::out_of_range"); delete[] rbytes; } @@ -394,15 +393,15 @@ TEST_F(DataInputStreamTest, test_readFullyNullArray) is.readFully(nullByteArray, 0, 0, 0); is.readFully(nullByteArray, 0, 1, 0); - ASSERT_THROW(is.readFully(nullByteArray, 0, 0, 1), NullPointerException) - << ("should throw NullPointerException"); + ASSERT_THROW(is.readFully(nullByteArray, 0, 0, 1), std::logic_error) + << ("should throw std::logic_error"); - ASSERT_THROW(is.readFully(nullByteArray, 0, 1, 1), NullPointerException) - << ("should throw NullPointerException"); + ASSERT_THROW(is.readFully(nullByteArray, 0, 1, 1), std::logic_error) + << ("should throw std::logic_error"); ASSERT_THROW(is.readFully(nullByteArray, 0, 1, Integer::MAX_VALUE), - NullPointerException) - << ("should throw NullPointerException"); + std::logic_error) + << ("should throw std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -415,17 +414,17 @@ TEST_F(DataInputStreamTest, test_readFullyNullStream) is.readFully(byteArray, (int)testData.length(), 1, 0); ASSERT_THROW(is.readFully(byteArray, (int)testData.length(), 1, 1), - NullPointerException) - << ("should throw NullPointerException"); + std::logic_error) + << ("should throw std::logic_error"); ASSERT_THROW(is.readFully(byteArray, (int)testData.length(), 0, 1), - NullPointerException) - << ("should throw NullPointerException"); + std::logic_error) + << ("should throw std::logic_error"); ASSERT_THROW( is.readFully(byteArray, (int)testData.length(), 0, Integer::MAX_VALUE), - NullPointerException) - << ("should throw NullPointerException"); + std::logic_error) + << ("should throw std::logic_error"); delete[] byteArray; } @@ -439,15 +438,15 @@ TEST_F(DataInputStreamTest, test_readFullyNullStreamNullArray) is.readFully(nullByteArray, 0, 0, 0); is.readFully(nullByteArray, 0, 1, 0); - ASSERT_THROW(is.readFully(nullByteArray, 0, 0, 1), NullPointerException) - << ("should throw NullPointerException"); + ASSERT_THROW(is.readFully(nullByteArray, 0, 0, 1), std::logic_error) + << ("should throw std::logic_error"); - ASSERT_THROW(is.readFully(nullByteArray, 0, 1, 1), NullPointerException) - << ("should throw NullPointerException"); + ASSERT_THROW(is.readFully(nullByteArray, 0, 1, 1), std::logic_error) + << ("should throw std::logic_error"); ASSERT_THROW(is.readFully(nullByteArray, 0, 1, Integer::MAX_VALUE), - NullPointerException) - << ("should throw NullPointerException"); + std::logic_error) + << ("should throw std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/io/DataOutputStreamTest.cpp b/activemq-cpp/src/test/decaf/io/DataOutputStreamTest.cpp index 107f45abc..b0f9fdff6 100644 --- a/activemq-cpp/src/test/decaf/io/DataOutputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/io/DataOutputStreamTest.cpp @@ -73,10 +73,9 @@ class DataOutputStreamTest : public ::testing::Test "RandomAccessFile\nTest_decaf_io_SyncFailedException\nTest_decaf_" "lang_AbstractMethodError\nTest_decaf_lang_" "ArithmeticException\nTest_decaf_lang_" - "ArrayIndexOutOfBoundsException\nTest_decaf_lang_" "ArrayStoreException\nTest_decaf_lang_Boolean\nTest_decaf_lang_" "Byte\nTest_decaf_lang_Character\nTest_decaf_lang_Class\nTest_" - "decaf_lang_ClassCastException\nTest_decaf_lang_" + "decaf_lang_" "ClassCircularityError\nTest_decaf_lang_ClassFormatError\nTest_" "decaf_lang_ClassLoader\nTest_decaf_lang_" "ClassNotFoundException\nTest_decaf_lang_" @@ -86,19 +85,19 @@ class DataOutputStreamTest : public ::testing::Test "lang_IllegalAccessError\nTest_decaf_lang_" "IllegalAccessException\nTest_decaf_lang_" "IllegalArgumentException\nTest_decaf_lang_" - "IllegalMonitorStateException\nTest_decaf_lang_" + "" "IllegalThreadStateException\nTest_decaf_lang_" "IncompatibleClassChangeError\nTest_decaf_lang_" - "IndexOutOfBoundsException\nTest_decaf_lang_" + "std::out_of_range\nTest_decaf_lang_" "InstantiationError\nTest_decaf_lang_InstantiationException\nTest_" "decaf_lang_Integer\nTest_decaf_lang_InternalError\nTest_decaf_" - "lang_InterruptedException\nTest_decaf_lang_LinkageError\nTest_" + "lang_RuntimeError\nTest_decaf_lang_LinkageError\nTest_" "decaf_lang_Long\nTest_decaf_lang_Math\nTest_decaf_lang_" - "NegativeArraySizeException\nTest_decaf_lang_" + "std::runtime_error\nTest_decaf_lang_" "NoClassDefFoundError\nTest_decaf_lang_NoSuchFieldError\nTest_" "decaf_lang_NoSuchMethodError\nTest_decaf_lang_" "NullPointerException\nTest_decaf_lang_Number\nTest_decaf_lang_" - "NumberFormatException\nTest_decaf_lang_Object\nTest_decaf_lang_" + "Object\nTest_decaf_lang_" "OutOfMemoryError\nTest_decaf_lang_RuntimeException\nTest_decaf_" "lang_SecurityManager\nTest_decaf_lang_Short\nTest_decaf_lang_" "StackOverflowError\nTest_decaf_lang_String\nTest_decaf_lang_" diff --git a/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.cpp b/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.cpp index f67d5f8cc..094547408 100644 --- a/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.cpp @@ -15,15 +15,16 @@ * limitations under the License. */ +#include #include #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::util; @@ -124,14 +125,16 @@ class MyInputStream : public InputStream if (buffer == NULL) { - throw NullPointerException(__FILE__, __LINE__, "Buffer was Null."); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Buffer was Null."); } if (offset > size || offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, + throw activemq::exceptions::OutOfRangeException( + std::string(__FILE__) + ":" + std::to_string(__LINE__) + ": " + "Offset + Length greater than the given buffer size."); } @@ -278,19 +281,23 @@ TEST_F(FilterInputStreamTest, testReadBIIIExceptions) MyInputStream myStream(testStr); FilterInputStream is(&myStream); - ASSERT_THROW(is.read(NULL, 1000, 0, 1001), NullPointerException) - << ("should throw NullPointerException"); + ASSERT_THROW(is.read(NULL, 1000, 0, 1001), + activemq::exceptions::IllegalStateException) + << ("should throw activemq::exceptions::IllegalStateException"); unsigned char buf[1000]; - ASSERT_THROW(is.read(buf, 1000, 0, 1001), IndexOutOfBoundsException) - << ("should throw IndexOutOfBoundsException"); + ASSERT_THROW(is.read(buf, 1000, 0, 1001), + activemq::exceptions::OutOfRangeException) + << ("should throw activemq::exceptions::OutOfRangeException"); - ASSERT_THROW(is.read(buf, 1000, 1001, 0), IndexOutOfBoundsException) - << ("should throw IndexOutOfBoundsException"); + ASSERT_THROW(is.read(buf, 1000, 1001, 0), + activemq::exceptions::OutOfRangeException) + << ("should throw activemq::exceptions::OutOfRangeException"); - ASSERT_THROW(is.read(buf, 1000, 500, 501), IndexOutOfBoundsException) - << ("should throw IndexOutOfBoundsException"); + ASSERT_THROW(is.read(buf, 1000, 500, 501), + activemq::exceptions::OutOfRangeException) + << ("should throw activemq::exceptions::OutOfRangeException"); { MyInputStream myStream(testStr); diff --git a/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.cpp b/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.cpp index 8d7764961..3e0513f9c 100644 --- a/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.cpp @@ -20,11 +20,11 @@ #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::io; using namespace decaf::util; @@ -54,10 +54,9 @@ class FilterOutputStreamTest : public ::testing::Test "RandomAccessFile\nTest_decaf_io_SyncFailedException\nTest_decaf_" "lang_AbstractMethodError\nTest_decaf_lang_" "ArithmeticException\nTest_decaf_lang_" - "ArrayIndexOutOfBoundsException\nTest_decaf_lang_" "ArrayStoreException\nTest_decaf_lang_Boolean\nTest_decaf_lang_" "Byte\nTest_decaf_lang_Character\nTest_decaf_lang_Class\nTest_" - "decaf_lang_ClassCastException\nTest_decaf_lang_" + "decaf_lang_" "ClassCircularityError\nTest_decaf_lang_ClassFormatError\nTest_" "decaf_lang_ClassLoader\nTest_decaf_lang_" "ClassNotFoundException\nTest_decaf_lang_" @@ -67,19 +66,19 @@ class FilterOutputStreamTest : public ::testing::Test "lang_IllegalAccessError\nTest_decaf_lang_" "IllegalAccessException\nTest_decaf_lang_" "IllegalArgumentException\nTest_decaf_lang_" - "IllegalMonitorStateException\nTest_decaf_lang_" + "" "IllegalThreadStateException\nTest_decaf_lang_" "IncompatibleClassChangeError\nTest_decaf_lang_" - "IndexOutOfBoundsException\nTest_decaf_lang_" + "std::out_of_range\nTest_decaf_lang_" "InstantiationError\nTest_decaf_lang_InstantiationException\nTest_" "decaf_lang_Integer\nTest_decaf_lang_InternalError\nTest_decaf_" - "lang_InterruptedException\nTest_decaf_lang_LinkageError\nTest_" + "lang_RuntimeError\nTest_decaf_lang_LinkageError\nTest_" "decaf_lang_Long\nTest_decaf_lang_Math\nTest_decaf_lang_" - "NegativeArraySizeException\nTest_decaf_lang_" + "std::runtime_error\nTest_decaf_lang_" "NoClassDefFoundError\nTest_decaf_lang_NoSuchFieldError\nTest_" "decaf_lang_NoSuchMethodError\nTest_decaf_lang_" "NullPointerException\nTest_decaf_lang_Number\nTest_decaf_lang_" - "NumberFormatException\nTest_decaf_lang_Object\nTest_decaf_lang_" + "Object\nTest_decaf_lang_" "OutOfMemoryError\nTest_decaf_lang_RuntimeException\nTest_decaf_" "lang_SecurityManager\nTest_decaf_lang_Short\nTest_decaf_lang_" "StackOverflowError\nTest_decaf_lang_String\nTest_decaf_lang_" @@ -216,19 +215,19 @@ TEST_F(FilterOutputStreamTest, testWriteBIIIExceptions) ByteArrayOutputStream baos; FilterOutputStream os(&baos); - ASSERT_THROW(os.write(NULL, 1000, 0, 1001), NullPointerException) - << ("Should have thrown an NullPointerException"); + ASSERT_THROW(os.write(NULL, 1000, 0, 1001), std::logic_error) + << ("Should have thrown an std::logic_error"); unsigned char buffer[1000]; - ASSERT_THROW(os.write(buffer, 1000, 0, 1001), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(os.write(buffer, 1000, 0, 1001), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(os.write(buffer, 1000, 1001, 0), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(os.write(buffer, 1000, 1001, 0), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(os.write(buffer, 1000, 500, 501), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(os.write(buffer, 1000, 500, 501), std::out_of_range) + << ("Should have thrown an std::out_of_range"); os.close(); diff --git a/activemq-cpp/src/test/decaf/io/InputStreamReaderTest.cpp b/activemq-cpp/src/test/decaf/io/InputStreamReaderTest.cpp index dc8bceda0..0a8e7629a 100644 --- a/activemq-cpp/src/test/decaf/io/InputStreamReaderTest.cpp +++ b/activemq-cpp/src/test/decaf/io/InputStreamReaderTest.cpp @@ -18,16 +18,15 @@ #include #include -#include #include #include +#include #include using namespace std; using namespace decaf; using namespace decaf::io; -using namespace decaf::lang::exceptions; class InputStreamReaderTest : public ::testing::Test { @@ -101,8 +100,8 @@ TEST_F(InputStreamReaderTest, testClose) //////////////////////////////////////////////////////////////////////////////// TEST_F(InputStreamReaderTest, testConstructorInputStream) { - ASSERT_THROW(InputStreamReader(NULL), NullPointerException) - << ("Should throw an NullPointerException"); + ASSERT_THROW(InputStreamReader(NULL), std::logic_error) + << ("Should throw an std::logic_error"); InputStreamReader* reader2 = new InputStreamReader(this->buffer1); reader2->close(); diff --git a/activemq-cpp/src/test/decaf/io/InputStreamTest.cpp b/activemq-cpp/src/test/decaf/io/InputStreamTest.cpp index ae6f4da90..df6668806 100644 --- a/activemq-cpp/src/test/decaf/io/InputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/io/InputStreamTest.cpp @@ -18,11 +18,11 @@ #include #include +#include using namespace std; using namespace decaf; using namespace decaf::io; -using namespace decaf::lang::exceptions; class InputStreamTest : public ::testing::Test { @@ -65,6 +65,6 @@ TEST_F(InputStreamTest, test) { MockInputStream stream; - ASSERT_THROW(stream.read(NULL, 0, 0, 1), NullPointerException) - << ("Should throw a NullPointerException"); + ASSERT_THROW(stream.read(NULL, 0, 0, 1), std::logic_error) + << ("Should throw a std::logic_error"); } diff --git a/activemq-cpp/src/test/decaf/io/OutputStreamTest.cpp b/activemq-cpp/src/test/decaf/io/OutputStreamTest.cpp index baca4976f..1ce4d68cd 100644 --- a/activemq-cpp/src/test/decaf/io/OutputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/io/OutputStreamTest.cpp @@ -22,7 +22,6 @@ using namespace std; using namespace decaf; using namespace decaf::io; -using namespace decaf::lang::exceptions; class OutputStreamTest : public ::testing::Test { diff --git a/activemq-cpp/src/test/decaf/io/OutputStreamWriterTest.cpp b/activemq-cpp/src/test/decaf/io/OutputStreamWriterTest.cpp index a8b67cd29..3d9d35283 100644 --- a/activemq-cpp/src/test/decaf/io/OutputStreamWriterTest.cpp +++ b/activemq-cpp/src/test/decaf/io/OutputStreamWriterTest.cpp @@ -22,12 +22,11 @@ #include #include #include -#include +#include using namespace std; using namespace decaf; using namespace decaf::io; -using namespace decaf::lang::exceptions; class OutputStreamWriterTest : public ::testing::Test { @@ -118,8 +117,8 @@ TEST_F(OutputStreamWriterTest, testFlush) //////////////////////////////////////////////////////////////////////////////// TEST_F(OutputStreamWriterTest, testWriteCharArrayIntIntInt) { - ASSERT_THROW(this->writer1->write(NULL, 0, 1, 1), NullPointerException) - << ("Should throw an NullPointerException"); + ASSERT_THROW(this->writer1->write(NULL, 0, 1, 1), std::logic_error) + << ("Should throw an std::logic_error"); this->writer1->write(TEST_STRING.c_str(), 1, 2); this->writer1->flush(); @@ -163,13 +162,11 @@ TEST_F(OutputStreamWriterTest, testWriteChar) //////////////////////////////////////////////////////////////////////////////// TEST_F(OutputStreamWriterTest, testWriteStringIntInt) { - ASSERT_THROW(this->writer1->write(string(""), 0, 1), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(this->writer1->write(string(""), 0, 1), std::out_of_range) + << ("Should throw an std::out_of_range"); - ASSERT_THROW(this->writer1->write(string("abc"), 1, 3), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(this->writer1->write(string("abc"), 1, 3), std::out_of_range) + << ("Should throw an std::out_of_range"); this->writer1->write("abc", 1, 2); this->writer1->flush(); @@ -189,8 +186,8 @@ TEST_F(OutputStreamWriterTest, testWriteStringIntInt) //////////////////////////////////////////////////////////////////////////////// TEST_F(OutputStreamWriterTest, testOutputStreamWriterOutputStream) { - ASSERT_THROW(OutputStreamWriter(NULL), NullPointerException) - << ("Should throw an NullPointerException"); + ASSERT_THROW(OutputStreamWriter(NULL), std::logic_error) + << ("Should throw an std::logic_error"); OutputStreamWriter* writer2 = new OutputStreamWriter(this->buffer1); writer2->close(); diff --git a/activemq-cpp/src/test/decaf/io/PushbackInputStreamTest.cpp b/activemq-cpp/src/test/decaf/io/PushbackInputStreamTest.cpp index 3ffcaf9f1..10939c731 100644 --- a/activemq-cpp/src/test/decaf/io/PushbackInputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/io/PushbackInputStreamTest.cpp @@ -24,7 +24,6 @@ using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class PushbackInputStreamTest : public ::testing::Test { @@ -52,11 +51,11 @@ std::string PushbackInputStreamTest::testString = "RandomAccessFile\n" "Test_java_io_SyncFailedException\nTest_java_lang_" "AbstractMethodError\nTest_java_lang_ArithmeticException\n" - "Test_java_lang_ArrayIndexOutOfBoundsException\nTest_java_lang_" + "Test_java_lang_" "ArrayStoreException\nTest_java_lang_Boolean\n" "Test_java_lang_Byte\nTest_java_lang_Character\nTest_java_lang_Class\nTest_" - "java_lang_ClassCastException\n" - "Test_java_lang_ClassCircularityError\nTest_java_lang_" + "java_lang_" + "ClassCircularityError\nTest_java_lang_" "ClassFormatError\nTest_java_lang_ClassLoader\n" "Test_java_lang_ClassNotFoundException\nTest_java_lang_" "CloneNotSupportedException\nTest_java_lang_Double\n" @@ -65,21 +64,20 @@ std::string PushbackInputStreamTest::testString = "Test_java_lang_Float\nTest_java_lang_IllegalAccessError\nTest_java_lang_" "IllegalAccessException\n" "Test_java_lang_IllegalArgumentException\nTest_java_lang_" - "IllegalMonitorStateException\n" + "" "Test_java_lang_IllegalThreadStateException\nTest_java_lang_" "IncompatibleClassChangeError\n" "Test_java_lang_IndexOutOfBoundsException\nTest_java_lang_" "InstantiationError\n" "Test_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_" "lang_InternalError\n" - "Test_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_" + "Test_java_lang_RuntimeError\nTest_java_lang_LinkageError\nTest_" "java_lang_Long\n" "Test_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_" "lang_NoClassDefFoundError\n" "Test_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\nTest_" "java_lang_NullPointerException\n" - "Test_java_lang_Number\nTest_java_lang_NumberFormatException\nTest_java_" - "lang_Object\n" + "Test_java_lang_Number\nTest_java_lang_Object\n" "Test_java_lang_OutOfMemoryError\nTest_java_lang_RuntimeException\nTest_" "java_lang_SecurityManager\n" "Test_java_lang_Short\nTest_java_lang_StackOverflowError\nTest_java_lang_" diff --git a/activemq-cpp/src/test/decaf/io/ReaderTest.cpp b/activemq-cpp/src/test/decaf/io/ReaderTest.cpp index f8734bb6c..9fb78b684 100644 --- a/activemq-cpp/src/test/decaf/io/ReaderTest.cpp +++ b/activemq-cpp/src/test/decaf/io/ReaderTest.cpp @@ -19,16 +19,15 @@ #include #include -#include #include +#include #include using namespace decaf; using namespace decaf::io; using namespace decaf::nio; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class ReaderTest : public ::testing::Test { @@ -118,8 +117,8 @@ TEST_F(ReaderTest, testReaderCharBufferNull) CharBuffer* charBuffer = NULL; - ASSERT_THROW(mockReader.read(charBuffer), NullPointerException) - << ("Should throw an NullPointerException"); + ASSERT_THROW(mockReader.read(charBuffer), std::logic_error) + << ("Should throw an std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/io/WriterTest.cpp b/activemq-cpp/src/test/decaf/io/WriterTest.cpp index 7b63b5218..1f54af7e4 100644 --- a/activemq-cpp/src/test/decaf/io/WriterTest.cpp +++ b/activemq-cpp/src/test/decaf/io/WriterTest.cpp @@ -18,14 +18,13 @@ #include #include -#include #include +#include using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::nio; -using namespace decaf::lang::exceptions; class WriterTest : public ::testing::Test { @@ -86,10 +85,9 @@ class MockWriter : public Writer if (offset + length > size) { - throw IndexOutOfBoundsException( - __FILE__, - __LINE__, - "offset + length must be less than size."); + throw std::out_of_range(std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + + "offset + length must be less than size."); } for (int i = 0; i < length; i++) diff --git a/activemq-cpp/src/test/decaf/lang/ArrayPointerTest.cpp b/activemq-cpp/src/test/decaf/lang/ArrayPointerTest.cpp old mode 100755 new mode 100644 index 69fb2eedb..8e17caab1 --- a/activemq-cpp/src/test/decaf/lang/ArrayPointerTest.cpp +++ b/activemq-cpp/src/test/decaf/lang/ArrayPointerTest.cpp @@ -20,17 +20,16 @@ #include #include #include -#include #include #include #include +#include #include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util::concurrent; class ArrayPointerTest : public ::testing::Test @@ -418,13 +417,11 @@ TEST_F(ArrayPointerTest, testOperators) ASSERT_TRUE(pointer1[0]->returnHello() == "Hello"); ASSERT_TRUE(pointer2[0]->returnHello() == "GoodBye"); - ASSERT_THROW(pointer2[1]->returnHello(), - decaf::lang::exceptions::IndexOutOfBoundsException) + ASSERT_THROW(pointer2[1]->returnHello(), std::out_of_range) << ("operator[] with bigger index than the array size should throw an " - "IndexOutOfBoundsException"); - ASSERT_THROW(pointer3[0].returnHello(), - decaf::lang::exceptions::NullPointerException) - << ("operator[] on a NULL Should Throw a NullPointerException"); + "std::out_of_range"); + ASSERT_THROW(pointer3[0].returnHello(), std::logic_error) + << ("operator[] on a NULL Should Throw a std::logic_error"); delete pointer1[0]; delete pointer2[0]; @@ -434,9 +431,8 @@ TEST_F(ArrayPointerTest, testOperators) pointer2.reset(NULL); - ASSERT_THROW(pointer2[0]->returnHello(), - decaf::lang::exceptions::NullPointerException) - << ("operator[] on a NULL Should Throw a NullPointerException"); + ASSERT_THROW(pointer2[0]->returnHello(), std::logic_error) + << ("operator[] on a NULL Should Throw a std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/lang/PointerTest.cpp b/activemq-cpp/src/test/decaf/lang/PointerTest.cpp index a733fad83..ec377cb4d 100644 --- a/activemq-cpp/src/test/decaf/lang/PointerTest.cpp +++ b/activemq-cpp/src/test/decaf/lang/PointerTest.cpp @@ -20,17 +20,17 @@ #include #include #include -#include #include #include +#include #include +#include #include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util::concurrent; class PointerTest : public ::testing::Test @@ -353,21 +353,17 @@ TEST_F(PointerTest, testOperators) ASSERT_TRUE((*pointer1).returnHello() == "Hello"); ASSERT_TRUE((*pointer2).returnHello() == "GoodBye"); - ASSERT_THROW((*pointer3).returnHello(), - decaf::lang::exceptions::NullPointerException) - << ("operator* on a NULL Should Throw a NullPointerException"); - ASSERT_THROW(pointer3->returnHello(), - decaf::lang::exceptions::NullPointerException) - << ("operator-> on a NULL Should Throw a NullPointerException"); + ASSERT_THROW((*pointer3).returnHello(), std::logic_error) + << ("operator* on a NULL Should Throw a std::logic_error"); + ASSERT_THROW(pointer3->returnHello(), std::logic_error) + << ("operator-> on a NULL Should Throw a std::logic_error"); pointer2.reset(NULL); - ASSERT_THROW((*pointer2).returnHello(), - decaf::lang::exceptions::NullPointerException) - << ("operator* on a NULL Should Throw a NullPointerException"); - ASSERT_THROW(pointer2->returnHello(), - decaf::lang::exceptions::NullPointerException) - << ("operator-> on a NULL Should Throw a NullPointerException"); + ASSERT_THROW((*pointer2).returnHello(), std::logic_error) + << ("operator* on a NULL Should Throw a std::logic_error"); + ASSERT_THROW(pointer2->returnHello(), std::logic_error) + << ("operator-> on a NULL Should Throw a std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -452,13 +448,13 @@ TEST_F(PointerTest, testDynamicCast) Pointer ptrTestClassA2; ASSERT_THROW(ptrTestClassA2 = pointer2.dynamicCast(), - ClassCastException) - << ("Should Throw a ClassCastException"); + std::bad_cast) + << ("Should throw std::bad_cast"); Pointer nullPointer; ASSERT_THROW(ptrTestClassA2 = nullPointer.dynamicCast(), - ClassCastException) - << ("Should Throw a ClassCastException"); + std::bad_cast) + << ("Should throw std::bad_cast"); Pointer basePointer = ptrTestClassA.dynamicCast(); diff --git a/activemq-cpp/src/test/decaf/lang/StringBufferTest.cpp b/activemq-cpp/src/test/decaf/lang/StringBufferTest.cpp index 7bb5c15ce..1fcec2f1a 100644 --- a/activemq-cpp/src/test/decaf/lang/StringBufferTest.cpp +++ b/activemq-cpp/src/test/decaf/lang/StringBufferTest.cpp @@ -26,17 +26,13 @@ #include #include #include -#include -#include -#include -#include #include +#include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class StringBufferTest : public ::testing::Test { @@ -68,8 +64,8 @@ TEST_F(StringBufferTest, testConstructorInt) StringBuffer sb(24); ASSERT_EQ(24, sb.capacity()); - ASSERT_THROW(StringBuffer(-1), NegativeArraySizeException) - << ("Should have thrown a NegativeArraySizeException"); + ASSERT_THROW(StringBuffer(-1), std::invalid_argument) + << ("Should have thrown a std::invalid_argument"); ASSERT_NO_THROW(StringBuffer(0)); } @@ -114,8 +110,8 @@ TEST_F(StringBufferTest, testAppendCharArray) sb.append("cd"); ASSERT_EQ(String("cd"), sb.toString()); - ASSERT_THROW(sb.append((const char*)NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.append((const char*)NULL), std::logic_error) + << ("Should have thrown a std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -140,17 +136,17 @@ TEST_F(StringBufferTest, testAppendCharArrayIntInt) sb.append("abcd", 2, 0); ASSERT_EQ(String(""), sb.toString()); - ASSERT_THROW(sb.append((const char*)NULL, 0, 2), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.append((const char*)NULL, 0, 2), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(sb.append("abcd", -1, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.append("abcd", -1, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.append("abcd", 0, -1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.append("abcd", 0, -1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.append("abcd", 2, 3), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.append("abcd", 2, 3), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -395,14 +391,14 @@ TEST_F(StringBufferTest, testCharAt) ASSERT_EQ((char)('0' + i), sb.charAt(i)); } - ASSERT_THROW(sb.charAt(-1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.charAt(-1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.charAt(fixture.length()), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.charAt(fixture.length()), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.charAt(fixture.length() + 1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.charAt(fixture.length() + 1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -429,17 +425,14 @@ TEST_F(StringBufferTest, testDeleteRange) ASSERT_EQ(0, sb.length()); } - ASSERT_THROW(StringBuffer(fixture).deleteRange(-1, 2), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(StringBuffer(fixture).deleteRange(-1, 2), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(StringBuffer(fixture).deleteRange(13, 12), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(StringBuffer(fixture).deleteRange(13, 12), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(StringBuffer(fixture).deleteRange(11, 12), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(StringBuffer(fixture).deleteRange(11, 12), std::out_of_range) + << ("Should have thrown std::out_of_range"); { StringBuffer sb; @@ -474,17 +467,16 @@ TEST_F(StringBufferTest, testDeleteCharAt) ASSERT_EQ(9, sb.length()); } - ASSERT_THROW(StringBuffer(fixture).deleteCharAt(-1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(StringBuffer(fixture).deleteCharAt(-1), std::out_of_range) + << ("Should have thrown std::out_of_range"); ASSERT_THROW(StringBuffer(fixture).deleteCharAt(fixture.length()), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + std::out_of_range) + << ("Should have thrown std::out_of_range"); ASSERT_THROW(StringBuffer(fixture).deleteCharAt(fixture.length() + 1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + std::out_of_range) + << ("Should have thrown std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -538,28 +530,26 @@ TEST_F(StringBufferTest, testGetChars) ASSERT_EQ(dst[i], fixtureChars[i]); } - ASSERT_THROW(sb.getChars(0, 10, dst, -1, 0), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(0, 10, dst, -1, 0), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.getChars(0, 10, (char*)NULL, 10, 0), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.getChars(0, 10, (char*)NULL, 10, 0), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(sb.getChars(-1, 10, dst, 10, 0), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(-1, 10, dst, 10, 0), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.getChars(0, 10, dst, 10, -1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(0, 10, dst, 10, -1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.getChars(5, 4, dst, 10, 0), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(5, 4, dst, 10, 0), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.getChars(0, 11, dst, 10, 0), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(0, 11, dst, 10, 0), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.getChars(0, 10, dst, 10, 5), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(0, 10, dst, 10, 5), std::out_of_range) + << ("Should have thrown std::out_of_range"); delete[] dst; delete[] fixtureChars; @@ -707,18 +697,17 @@ TEST_F(StringBufferTest, testSubSequence) ss.reset(sb.subSequence(0, 0)); ASSERT_EQ(std::string(""), ss->toString()); - ASSERT_THROW(sb.subSequence(-1, 1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.subSequence(-1, 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.subSequence(0, fixture.length() + 1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.subSequence(0, fixture.length() + 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.subSequence(0, -1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.subSequence(0, -1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.subSequence(3, 2), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.subSequence(3, 2), std::out_of_range) + << ("Should have thrown std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -732,15 +721,14 @@ TEST_F(StringBufferTest, testSubstringInt) ss = sb.substring(10); ASSERT_EQ(String(""), ss); - ASSERT_THROW(sb.substring(-1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(-1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.substring(fixture.length() + 1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(fixture.length() + 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.substring(0, -1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(0, -1), std::out_of_range) + << ("Should have thrown std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -754,18 +742,17 @@ TEST_F(StringBufferTest, testSubstringIntInt) ss = sb.substring(0, 0); ASSERT_EQ(String(), ss); - ASSERT_THROW(sb.substring(-1, 1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(-1, 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.substring(0, fixture.length() + 1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(0, fixture.length() + 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.substring(0, -1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(0, -1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.substring(3, 2), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(3, 2), std::out_of_range) + << ("Should have thrown std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -794,11 +781,11 @@ TEST_F(StringBufferTest, testInsertChar) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 'a'), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 'a'), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 'a'), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 'a'), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -827,11 +814,11 @@ TEST_F(StringBufferTest, testInsertBoolean) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, false), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, false), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, false), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, false), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -855,14 +842,14 @@ TEST_F(StringBufferTest, testInsertCharArray) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(0, (const char*)NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.insert(0, (const char*)NULL), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(sb.insert(-1, "Test"), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, "Test"), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, "Test"), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, "Test"), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -901,23 +888,23 @@ TEST_F(StringBufferTest, testInsertCharArrayWithOffset) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(0, (const char*)NULL, 0, 2), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.insert(0, (const char*)NULL, 0, 2), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(sb.insert(-1, "ab", 0, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, "ab", 0, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, "ab", 0, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, "ab", 0, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(4, "ab", 0, -1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(4, "ab", 0, -1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(4, "ab", -1, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(4, "ab", -1, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(4, "ab", 0, 3), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(4, "ab", 0, 3), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -941,11 +928,11 @@ TEST_F(StringBufferTest, testInsertString) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, String("fixture")), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, String("fixture")), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, String("fixture")), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, String("fixture")), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -969,12 +956,11 @@ TEST_F(StringBufferTest, testInsertStdString) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, std::string("fixture")), - IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, std::string("fixture")), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, std::string("fixture")), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, std::string("fixture")), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1004,11 +990,11 @@ TEST_F(StringBufferTest, testInsertCharSequence) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, &ab), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, &ab), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, &ab), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, &ab), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1053,20 +1039,20 @@ TEST_F(StringBufferTest, testInsertCharSequenceIntInt) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, &ab, 0, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, &ab, 0, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, &ab, 0, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, &ab, 0, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, &ab, -1, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, &ab, -1, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, &ab, 0, -1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, &ab, 0, -1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, &ab, 0, 3), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, &ab, 0, 3), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1095,11 +1081,11 @@ TEST_F(StringBufferTest, testInsertDouble) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 1.0), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 1.0), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 1.0), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 1.0), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1128,11 +1114,11 @@ TEST_F(StringBufferTest, testInsertFloat) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 1.0f), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 1.0f), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 1.0f), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 1.0f), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1161,11 +1147,11 @@ TEST_F(StringBufferTest, testInsertShort) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, (short)1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, (short)1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, (short)1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, (short)1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1194,11 +1180,11 @@ TEST_F(StringBufferTest, testInsertInt) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1227,11 +1213,11 @@ TEST_F(StringBufferTest, testInsertLong) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 1LL), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 1LL), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 1LL), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 1LL), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1245,11 +1231,11 @@ TEST_F(StringBufferTest, testInsertRawPointer) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 1LL), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 1LL), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 1LL), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 1LL), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1263,11 +1249,11 @@ TEST_F(StringBufferTest, testInsertPointer) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, obj), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, obj), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, obj), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, obj), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1296,17 +1282,17 @@ TEST_F(StringBufferTest, testReplace) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.replace(1, 2, (const char*)NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.replace(1, 2, (const char*)NULL), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(sb.replace(-1, 2, "11"), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.replace(-1, 2, "11"), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.replace(5, 2, "11"), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.replace(5, 2, "11"), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.replace(3, 2, "11"), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.replace(3, 2, "11"), std::out_of_range) + << ("Should have thrown a std::out_of_range"); StringBuffer buffer("1234567"); buffer.replace(2, 6, "XXX"); diff --git a/activemq-cpp/src/test/decaf/lang/StringBuilderTest.cpp b/activemq-cpp/src/test/decaf/lang/StringBuilderTest.cpp index 504fac064..0cce72278 100644 --- a/activemq-cpp/src/test/decaf/lang/StringBuilderTest.cpp +++ b/activemq-cpp/src/test/decaf/lang/StringBuilderTest.cpp @@ -26,17 +26,13 @@ #include #include #include -#include -#include -#include -#include #include +#include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class StringBuilderTest : public ::testing::Test { @@ -68,8 +64,8 @@ TEST_F(StringBuilderTest, testConstructorInt) StringBuilder sb(24); ASSERT_EQ(24, sb.capacity()); - ASSERT_THROW(StringBuilder(-1), NegativeArraySizeException) - << ("Should have thrown a NegativeArraySizeException"); + ASSERT_THROW(StringBuilder(-1), std::invalid_argument) + << ("Should have thrown a std::invalid_argument"); ASSERT_NO_THROW(StringBuilder(0)); } @@ -114,8 +110,8 @@ TEST_F(StringBuilderTest, testAppendCharArray) sb.append("cd"); ASSERT_EQ(String("cd"), sb.toString()); - ASSERT_THROW(sb.append((const char*)NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.append((const char*)NULL), std::logic_error) + << ("Should have thrown a std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -140,17 +136,17 @@ TEST_F(StringBuilderTest, testAppendCharArrayIntInt) sb.append("abcd", 2, 0); ASSERT_EQ(String(""), sb.toString()); - ASSERT_THROW(sb.append((const char*)NULL, 0, 2), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.append((const char*)NULL, 0, 2), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(sb.append("abcd", -1, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.append("abcd", -1, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.append("abcd", 0, -1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.append("abcd", 0, -1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.append("abcd", 2, 3), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.append("abcd", 2, 3), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -395,14 +391,14 @@ TEST_F(StringBuilderTest, testCharAt) ASSERT_EQ((char)('0' + i), sb.charAt(i)); } - ASSERT_THROW(sb.charAt(-1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.charAt(-1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.charAt(fixture.length()), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.charAt(fixture.length()), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.charAt(fixture.length() + 1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.charAt(fixture.length() + 1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -429,17 +425,14 @@ TEST_F(StringBuilderTest, testDeleteRange) ASSERT_EQ(0, sb.length()); } - ASSERT_THROW(StringBuilder(fixture).deleteRange(-1, 2), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(StringBuilder(fixture).deleteRange(-1, 2), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(StringBuilder(fixture).deleteRange(13, 12), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(StringBuilder(fixture).deleteRange(13, 12), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(StringBuilder(fixture).deleteRange(11, 12), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(StringBuilder(fixture).deleteRange(11, 12), std::out_of_range) + << ("Should have thrown std::out_of_range"); { StringBuilder sb; @@ -474,17 +467,16 @@ TEST_F(StringBuilderTest, testDeleteCharAt) ASSERT_EQ(9, sb.length()); } - ASSERT_THROW(StringBuilder(fixture).deleteCharAt(-1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(StringBuilder(fixture).deleteCharAt(-1), std::out_of_range) + << ("Should have thrown std::out_of_range"); ASSERT_THROW(StringBuilder(fixture).deleteCharAt(fixture.length()), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + std::out_of_range) + << ("Should have thrown std::out_of_range"); ASSERT_THROW(StringBuilder(fixture).deleteCharAt(fixture.length() + 1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + std::out_of_range) + << ("Should have thrown std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -536,28 +528,26 @@ TEST_F(StringBuilderTest, testGetChars) // fixture.getChars(5, 10, fixtureChars, 1); // assertTrue(Arrays.equals(fixtureChars, dst)); - ASSERT_THROW(sb.getChars(0, 10, dst, -1, 0), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(0, 10, dst, -1, 0), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.getChars(0, 10, (char*)NULL, 10, 0), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.getChars(0, 10, (char*)NULL, 10, 0), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(sb.getChars(-1, 10, dst, 10, 0), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(-1, 10, dst, 10, 0), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.getChars(0, 10, dst, 10, -1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(0, 10, dst, 10, -1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.getChars(5, 4, dst, 10, 0), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(5, 4, dst, 10, 0), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.getChars(0, 11, dst, 10, 0), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(0, 11, dst, 10, 0), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.getChars(0, 10, dst, 10, 5), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.getChars(0, 10, dst, 10, 5), std::out_of_range) + << ("Should have thrown std::out_of_range"); delete[] dst; delete[] fixtureChars; @@ -705,18 +695,17 @@ TEST_F(StringBuilderTest, testSubSequence) ss.reset(sb.subSequence(0, 0)); ASSERT_EQ(std::string(""), ss->toString()); - ASSERT_THROW(sb.subSequence(-1, 1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.subSequence(-1, 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.subSequence(0, fixture.length() + 1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.subSequence(0, fixture.length() + 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.subSequence(0, -1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.subSequence(0, -1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.subSequence(3, 2), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.subSequence(3, 2), std::out_of_range) + << ("Should have thrown std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -730,15 +719,14 @@ TEST_F(StringBuilderTest, testSubstringInt) ss = sb.substring(10); ASSERT_EQ(String(""), ss); - ASSERT_THROW(sb.substring(-1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(-1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.substring(fixture.length() + 1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(fixture.length() + 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.substring(0, -1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(0, -1), std::out_of_range) + << ("Should have thrown std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -752,18 +740,17 @@ TEST_F(StringBuilderTest, testSubstringIntInt) ss = sb.substring(0, 0); ASSERT_EQ(String(), ss); - ASSERT_THROW(sb.substring(-1, 1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(-1, 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.substring(0, fixture.length() + 1), - StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(0, fixture.length() + 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.substring(0, -1), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(0, -1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(sb.substring(3, 2), StringIndexOutOfBoundsException) - << ("Should have thrown a StringIndexOutOfBoundsException"); + ASSERT_THROW(sb.substring(3, 2), std::out_of_range) + << ("Should have thrown std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -792,11 +779,11 @@ TEST_F(StringBuilderTest, testInsertChar) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 'a'), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 'a'), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 'a'), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 'a'), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -825,11 +812,11 @@ TEST_F(StringBuilderTest, testInsertBoolean) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, false), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, false), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, false), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, false), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -853,14 +840,14 @@ TEST_F(StringBuilderTest, testInsertCharArray) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(0, (const char*)NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.insert(0, (const char*)NULL), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(sb.insert(-1, "Test"), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, "Test"), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, "Test"), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, "Test"), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -899,23 +886,23 @@ TEST_F(StringBuilderTest, testInsertCharArrayWithOffset) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(0, (const char*)NULL, 0, 2), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.insert(0, (const char*)NULL, 0, 2), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(sb.insert(-1, "ab", 0, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, "ab", 0, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, "ab", 0, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, "ab", 0, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(4, "ab", 0, -1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(4, "ab", 0, -1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(4, "ab", -1, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(4, "ab", -1, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(4, "ab", 0, 3), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(4, "ab", 0, 3), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -939,11 +926,11 @@ TEST_F(StringBuilderTest, testInsertString) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, String("fixture")), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, String("fixture")), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, String("fixture")), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, String("fixture")), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -967,12 +954,11 @@ TEST_F(StringBuilderTest, testInsertStdString) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, std::string("fixture")), - IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, std::string("fixture")), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, std::string("fixture")), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, std::string("fixture")), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1002,11 +988,11 @@ TEST_F(StringBuilderTest, testInsertCharSequence) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, &ab), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, &ab), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, &ab), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, &ab), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1051,20 +1037,20 @@ TEST_F(StringBuilderTest, testInsertCharSequenceIntInt) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, &ab, 0, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, &ab, 0, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, &ab, 0, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, &ab, 0, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, &ab, -1, 2), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, &ab, -1, 2), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, &ab, 0, -1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, &ab, 0, -1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, &ab, 0, 3), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, &ab, 0, 3), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1093,11 +1079,11 @@ TEST_F(StringBuilderTest, testInsertDouble) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 1.0), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 1.0), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 1.0), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 1.0), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1126,11 +1112,11 @@ TEST_F(StringBuilderTest, testInsertFloat) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 1.0f), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 1.0f), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 1.0f), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 1.0f), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1159,11 +1145,11 @@ TEST_F(StringBuilderTest, testInsertShort) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, (short)1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, (short)1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, (short)1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, (short)1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1192,11 +1178,11 @@ TEST_F(StringBuilderTest, testInsertInt) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1225,11 +1211,11 @@ TEST_F(StringBuilderTest, testInsertLong) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 1LL), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 1LL), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 1LL), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 1LL), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1243,11 +1229,11 @@ TEST_F(StringBuilderTest, testInsertRawPointer) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, 1LL), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, 1LL), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, 1LL), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, 1LL), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1261,11 +1247,11 @@ TEST_F(StringBuilderTest, testInsertPointer) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.insert(-1, obj), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(-1, obj), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.insert(5, obj), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.insert(5, obj), std::out_of_range) + << ("Should have thrown a std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1294,17 +1280,17 @@ TEST_F(StringBuilderTest, testReplace) sb.setLength(0); sb.append(fixture); - ASSERT_THROW(sb.replace(1, 2, (const char*)NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(sb.replace(1, 2, (const char*)NULL), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(sb.replace(-1, 2, "11"), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.replace(-1, 2, "11"), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.replace(5, 2, "11"), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.replace(5, 2, "11"), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(sb.replace(3, 2, "11"), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(sb.replace(3, 2, "11"), std::out_of_range) + << ("Should have thrown a std::out_of_range"); StringBuilder buffer("1234567"); buffer.replace(2, 6, "XXX"); diff --git a/activemq-cpp/src/test/decaf/lang/StringTest.cpp b/activemq-cpp/src/test/decaf/lang/StringTest.cpp index 2671e6843..79942fd03 100644 --- a/activemq-cpp/src/test/decaf/lang/StringTest.cpp +++ b/activemq-cpp/src/test/decaf/lang/StringTest.cpp @@ -19,17 +19,14 @@ #include #include -#include -#include -#include #include +#include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class StringTest : public ::testing::Test { @@ -57,8 +54,8 @@ TEST_F(StringTest, testDefaultConstructor) ASSERT_TRUE(test.length() == 0); ASSERT_TRUE(test.isEmpty() == true); - ASSERT_THROW(test.charAt(1), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(test.charAt(1), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -74,8 +71,8 @@ TEST_F(StringTest, testConstructorStdString) ASSERT_TRUE(test == stdString) << ("String and std::string should be equal"); - ASSERT_THROW(test.charAt(5), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(test.charAt(5), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -90,11 +87,11 @@ TEST_F(StringTest, testConstructorCString) ASSERT_TRUE(test == cstring) << ("String and C string should be equal"); - ASSERT_THROW(test.charAt(5), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(test.charAt(5), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(String((const char*)NULL), NullPointerException) - << ("Should have thrown an NullPointerException"); + ASSERT_THROW(String((const char*)NULL), std::logic_error) + << ("Should have thrown an std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -110,14 +107,14 @@ TEST_F(StringTest, testConstructorCStringWithSize) ASSERT_TRUE(test == expected) << ("String and C string should be equal"); - ASSERT_THROW(test.charAt(5), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(test.charAt(5), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(String((const char*)NULL, 10), NullPointerException) - << ("Should have thrown an NullPointerException"); + ASSERT_THROW(String((const char*)NULL, 10), std::logic_error) + << ("Should have thrown an std::logic_error"); - ASSERT_THROW(String(cstring, -1), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(String(cstring, -1), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -133,17 +130,17 @@ TEST_F(StringTest, testConstructorCStringOffsetAndLength) ASSERT_TRUE(test == expected) << ("String and C string should be equal"); - ASSERT_THROW(test.charAt(5), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(test.charAt(5), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(String((const char*)NULL, 1, 20), NullPointerException) - << ("Should have thrown an NullPointerException"); + ASSERT_THROW(String((const char*)NULL, 1, 20), std::logic_error) + << ("Should have thrown an std::logic_error"); - ASSERT_THROW(String(cstring, -1, 5), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(String(cstring, -1, 5), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(String(cstring, 1, -5), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(String(cstring, 1, -5), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -159,20 +156,20 @@ TEST_F(StringTest, testConstructorCStringSizeOffsetAndLength) ASSERT_TRUE(test == expected) << ("String and C string should be equal"); - ASSERT_THROW(test.charAt(5), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(test.charAt(5), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(String((const char*)NULL, 7, 1, 4), NullPointerException) - << ("Should have thrown an NullPointerException"); + ASSERT_THROW(String((const char*)NULL, 7, 1, 4), std::logic_error) + << ("Should have thrown an std::logic_error"); - ASSERT_THROW(String(cstring, -1, 0, 5), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(String(cstring, -1, 0, 5), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(String(cstring, 7, -1, 5), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(String(cstring, 7, -1, 5), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(String(cstring, 7, 1, -5), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(String(cstring, 7, 1, -5), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -187,8 +184,8 @@ TEST_F(StringTest, testConstructorString) ASSERT_TRUE(test == original) << ("String and std::string should be equal"); - ASSERT_THROW(test.charAt(5), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(test.charAt(5), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -201,8 +198,8 @@ TEST_F(StringTest, testConstructorCharFill) ASSERT_TRUE(String('A', 0).isEmpty()) << ("String should be empty"); - ASSERT_THROW(String('A', -1), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(String('A', -1), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -419,14 +416,14 @@ TEST_F(StringTest, testSubstringExceptions) { const String input("HelloWorld"); - ASSERT_THROW(input.substring(-1, 1), StringIndexOutOfBoundsException) - << ("Should have thrown an StringIndexOutOfBoundsException"); + ASSERT_THROW(input.substring(-1, 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(input.substring(4, 1), StringIndexOutOfBoundsException) - << ("Should have thrown an StringIndexOutOfBoundsException"); + ASSERT_THROW(input.substring(4, 1), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(input.substring(0, 100), StringIndexOutOfBoundsException) - << ("Should have thrown an StringIndexOutOfBoundsException"); + ASSERT_THROW(input.substring(0, 100), std::out_of_range) + << ("Should have thrown std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -971,8 +968,8 @@ TEST_F(StringTest, testCompareToCString) ASSERT_TRUE(!(String("A").compareTo("a") == 0)) << ("Considered case to not be of importance"); - ASSERT_THROW(String("").compareTo((const char*)NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(String("").compareTo((const char*)NULL), std::logic_error) + << ("Should have thrown a std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -1013,8 +1010,8 @@ TEST_F(StringTest, testCompareToIgnoreCaseCString) ASSERT_EQ(0, String("A").compareToIgnoreCase("a")) << ("Considered case to not be of importance"); - ASSERT_THROW(String("").compareTo((const char*)NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(String("").compareTo((const char*)NULL), std::logic_error) + << ("Should have thrown a std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -1122,8 +1119,8 @@ TEST_F(StringTest, testOperatorLessCString) ASSERT_TRUE(upper < lower) << ("Failed comparison"); ASSERT_TRUE(!(upper < "HELLOWORLD")) << ("Failed comparison"); - ASSERT_THROW((void)(upper < NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW((void)(upper < NULL), std::logic_error) + << ("Should have thrown a std::logic_error"); // test lhs as std::string ASSERT_TRUE("aaab" < String("aaac")) << ("Failed comparison"); @@ -1163,8 +1160,8 @@ TEST_F(StringTest, testOperatorGreaterCString) ASSERT_TRUE(lower > upper) << ("Failed comparison"); ASSERT_TRUE(!(lower > "helloworld")) << ("Failed comparison"); - ASSERT_THROW((void)(lower < NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW((void)(lower < NULL), std::logic_error) + << ("Should have thrown a std::logic_error"); // test lhs as C string ASSERT_TRUE("aaac" > String("aaab")) << ("Failed comparison"); @@ -1219,29 +1216,29 @@ TEST_F(StringTest, testGetChars) hello.getChars(0, 5, buffer, 10, 0); ASSERT_EQ(String("Hello"), String(buffer)); - ASSERT_THROW(hello.getChars(-1, 1, buffer, 10, 0), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(hello.getChars(-1, 1, buffer, 10, 0), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(hello.getChars(1, -1, buffer, 10, 0), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(hello.getChars(1, -1, buffer, 10, 0), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(hello.getChars(0, 1, buffer, 10, -1), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(hello.getChars(0, 1, buffer, 10, -1), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(hello.getChars(1, 1, buffer, -1, 0), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(hello.getChars(1, 1, buffer, -1, 0), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(hello.getChars(0, 2, (char*)NULL, 10, 0), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(hello.getChars(0, 2, (char*)NULL, 10, 0), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(hello.getChars(15, 1, buffer, 10, 0), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(hello.getChars(15, 1, buffer, 10, 0), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(hello.getChars(0, 12, buffer, 10, 0), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(hello.getChars(0, 12, buffer, 10, 0), std::out_of_range) + << ("Should have thrown a std::out_of_range"); - ASSERT_THROW(hello.getChars(2, 10, buffer, 10, 4), IndexOutOfBoundsException) - << ("Should have thrown a IndexOutOfBoundsException"); + ASSERT_THROW(hello.getChars(2, 10, buffer, 10, 4), std::out_of_range) + << ("Should have thrown a std::out_of_range"); delete[] buffer; } diff --git a/activemq-cpp/src/test/decaf/lang/ThreadLocalTest.cpp b/activemq-cpp/src/test/decaf/lang/ThreadLocalTest.cpp index 6d29e0ee5..0489e678b 100644 --- a/activemq-cpp/src/test/decaf/lang/ThreadLocalTest.cpp +++ b/activemq-cpp/src/test/decaf/lang/ThreadLocalTest.cpp @@ -17,18 +17,17 @@ #include +#include #include #include -#include -#include #include +#include #include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -153,7 +152,7 @@ TEST_F(ThreadLocalTest, testGet) { t.join(); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { FAIL() << ("Interrupted!!"); } @@ -213,7 +212,7 @@ TEST_F(ThreadLocalTest, testSet) { t.join(); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { FAIL() << ("Interrupted!!"); } diff --git a/activemq-cpp/src/test/decaf/lang/ThreadTest.cpp b/activemq-cpp/src/test/decaf/lang/ThreadTest.cpp index 137280fc6..1dc1caeb3 100644 --- a/activemq-cpp/src/test/decaf/lang/ThreadTest.cpp +++ b/activemq-cpp/src/test/decaf/lang/ThreadTest.cpp @@ -17,19 +17,18 @@ #include +#include #include -#include -#include #include #include #include +#include #include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -61,7 +60,7 @@ namespace lang lock.wait(delay); } } - catch (decaf::lang::exceptions::InterruptedException& e) + catch (std::runtime_error& e) { return; } @@ -118,7 +117,7 @@ namespace lang { lock.wait(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -303,7 +302,7 @@ namespace lang virtual void run() { Thread::sleep(100); - throw RuntimeException(__FILE__, __LINE__, "Planned"); + throw Exception(__FILE__, __LINE__, "Planned"); } }; @@ -329,7 +328,7 @@ namespace lang { Thread::sleep(10000); } - catch (InterruptedException& ex) + catch (std::runtime_error& ex) { interrupted = true; } @@ -369,7 +368,7 @@ namespace lang { parent->join(10000); } - catch (InterruptedException& ex) + catch (std::runtime_error& ex) { interrupted = true; } @@ -408,7 +407,7 @@ namespace lang { lock.wait(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { interrupted = true; } @@ -494,7 +493,7 @@ TEST_F(ThreadTest, testRun) ASSERT_TRUE(rt.didThreadRun) << ("Thread did not run"); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { FAIL() << ("Joined thread was interrupted"); } @@ -655,7 +654,7 @@ TEST_F(ThreadTest, testIsAlive) { runnable->lock.wait(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -666,7 +665,7 @@ TEST_F(ThreadTest, testIsAlive) { ct.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { FAIL() << ("Thread did not die"); } @@ -693,7 +692,7 @@ TEST_F(ThreadTest, testSleep) Thread::sleep(1000); endTime = System::currentTimeMillis(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { FAIL() << ("Unexpected interrupt received"); } @@ -701,7 +700,7 @@ TEST_F(ThreadTest, testSleep) ASSERT_TRUE((endTime - startTime) >= 800) << ("Failed to sleep long enough"); - ASSERT_THROW(Thread::sleep(-1), IllegalArgumentException) + ASSERT_THROW(Thread::sleep(-1), std::invalid_argument) << ("Should throw an IllegalArgumentException"); } @@ -717,7 +716,7 @@ TEST_F(ThreadTest, testSleep2Arg) Thread::sleep(1000, 10); endTime = System::currentTimeMillis(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { FAIL() << ("Unexpected interrupt received"); } @@ -725,10 +724,10 @@ TEST_F(ThreadTest, testSleep2Arg) ASSERT_TRUE((endTime - startTime) >= 800) << ("Failed to sleep long enough"); - ASSERT_THROW(Thread::sleep(-1, 0), IllegalArgumentException) + ASSERT_THROW(Thread::sleep(-1, 0), std::invalid_argument) << ("Should throw an IllegalArgumentException"); - ASSERT_THROW(Thread::sleep(1000, 10000000), IllegalArgumentException) + ASSERT_THROW(Thread::sleep(1000, 10000000), std::invalid_argument) << ("Should throw an IllegalArgumentException"); } @@ -747,7 +746,7 @@ TEST_F(ThreadTest, testGetState) { runnable->lock.wait(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -759,7 +758,7 @@ TEST_F(ThreadTest, testGetState) { ct.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { FAIL() << ("Thread did not die"); } @@ -816,7 +815,7 @@ TEST_F(ThreadTest, testInterrupt) ct.lock.wait(); } } - catch (InterruptedException& e) + catch (std::runtime_error& e) { interrupted = true; } @@ -840,7 +839,7 @@ TEST_F(ThreadTest, testInterrupt) } Thread::sleep(20000); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { interrupted = true; } diff --git a/activemq-cpp/src/test/decaf/net/ServerSocketTest.cpp b/activemq-cpp/src/test/decaf/net/ServerSocketTest.cpp index ba05ad4e4..24f8f1058 100644 --- a/activemq-cpp/src/test/decaf/net/ServerSocketTest.cpp +++ b/activemq-cpp/src/test/decaf/net/ServerSocketTest.cpp @@ -26,7 +26,6 @@ using namespace decaf; using namespace decaf::net; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class ServerSocketTest : public ::testing::Test { @@ -71,7 +70,7 @@ class SocketClient : public Runnable this->clientS.reset(new Socket("127.0.0.1", port)); Thread::sleep(1000); } - catch (InterruptedException& ex) + catch (std::runtime_error& ex) { } catch (Exception& ex) @@ -137,7 +136,7 @@ TEST_F(ServerSocketTest, testConstructor) this->ssconn = s.accept(); this->ssconn->close(); } - catch (InterruptedException& ex) + catch (std::runtime_error& ex) { } catch (Exception& ex) @@ -247,7 +246,7 @@ TEST_F(ServerSocketTest, testAccept) // do { // Thread::sleep( 500 ); // } while( !thread.isAlive() ); - // } catch( InterruptedException& e ) { + // } catch( std::runtime_error& e ) { // } // // ss.close(); @@ -256,7 +255,7 @@ TEST_F(ServerSocketTest, testAccept) // do { // try { // Thread::sleep( 500 ); - // } catch( InterruptedException& e ) { + // } catch( std::runtime_error& e ) { // } // // if( interrupted ) { @@ -370,9 +369,8 @@ void ServerSocketTest::startClient(int port) { Thread::sleep(1000); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { - FAIL() << (std::string("Exception during startClinet()") + - e.getMessage()); + FAIL() << (std::string("Exception during startClinet()") + e.what()); } } diff --git a/activemq-cpp/src/test/decaf/net/SocketTest.cpp b/activemq-cpp/src/test/decaf/net/SocketTest.cpp index a5c0222d5..bcff713f4 100644 --- a/activemq-cpp/src/test/decaf/net/SocketTest.cpp +++ b/activemq-cpp/src/test/decaf/net/SocketTest.cpp @@ -30,6 +30,7 @@ #include #include #include +#include using namespace std; using namespace decaf; @@ -37,7 +38,6 @@ using namespace decaf::io; using namespace decaf::net; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class SocketTest : public ::testing::Test { @@ -60,10 +60,10 @@ TEST_F(SocketTest, testConnectPortOutOfRange) { Socket s; - ASSERT_THROW(s.connect("0.0.0.0", 70000), IllegalArgumentException) + ASSERT_THROW(s.connect("0.0.0.0", 70000), std::invalid_argument) << ("Should Throw an IllegalArguementException"); - ASSERT_THROW(s.connect("0.0.0.0", 70000, 1000), IllegalArgumentException) + ASSERT_THROW(s.connect("0.0.0.0", 70000, 1000), std::invalid_argument) << ("Should Throw an IllegalArguementException"); } @@ -408,7 +408,7 @@ TEST_F(SocketTest, testGetOutputStream) { Thread::sleep(200); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } @@ -434,7 +434,7 @@ TEST_F(SocketTest, testGetOutputStream) { Thread::sleep(200); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } diff --git a/activemq-cpp/src/test/decaf/net/URITest.cpp b/activemq-cpp/src/test/decaf/net/URITest.cpp index 41c30dc0d..6200ea87d 100644 --- a/activemq-cpp/src/test/decaf/net/URITest.cpp +++ b/activemq-cpp/src/test/decaf/net/URITest.cpp @@ -21,12 +21,12 @@ #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class URITest : public ::testing::Test { @@ -628,7 +628,7 @@ TEST_F(URITest, testCompareToTwo) //////////////////////////////////////////////////////////////////////////////// TEST_F(URITest, testCreate) { - ASSERT_THROW(URI::create("a scheme://reg/"), IllegalArgumentException) + ASSERT_THROW(URI::create("a scheme://reg/"), std::invalid_argument) << ("IllegalArgumentException expected but not received."); } @@ -1857,7 +1857,7 @@ TEST_F(URITest, testToURL) URI(relativeuris[i]).toURL(); FAIL() << ("Expected IllegalArgumentException not thrown"); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { // Expected } diff --git a/activemq-cpp/src/test/decaf/net/URLTest.cpp b/activemq-cpp/src/test/decaf/net/URLTest.cpp index 8d01a8d9b..d8ebe8394 100644 --- a/activemq-cpp/src/test/decaf/net/URLTest.cpp +++ b/activemq-cpp/src/test/decaf/net/URLTest.cpp @@ -19,18 +19,16 @@ #include #include -#include -#include #include #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::net; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class URLTest : public ::testing::Test { @@ -580,45 +578,44 @@ TEST_F(URLTest, testURLStreamHandlerParseURL) MyURLStreamHandler handler; ASSERT_THROW(handler.parse(url, "//", 0, Integer::MIN_VALUE), - StringIndexOutOfBoundsException) - << ("Should have thrown an StringIndexOutOfBoundsException"); + std::out_of_range) + << ("Should have thrown std::out_of_range"); ASSERT_THROW(handler.parse(url, "1234//", 4, Integer::MIN_VALUE), - StringIndexOutOfBoundsException) - << ("Should have thrown an StringIndexOutOfBoundsException"); + std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(handler.parse(url, "1", -1, 0), StringIndexOutOfBoundsException) - << ("Should have thrown an StringIndexOutOfBoundsException"); + ASSERT_THROW(handler.parse(url, "1", -1, 0), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(handler.parse(url, "1", 3, 2), SecurityException) + ASSERT_THROW(handler.parse(url, "1", 3, 2), std::logic_error) << ("Should have thrown an SecurityException"); ASSERT_THROW(handler.parse(url, "11", 1, Integer::MIN_VALUE), - SecurityException) + std::logic_error) << ("Should have thrown an SecurityException"); ASSERT_THROW(handler.parse(url, "any", 10, Integer::MIN_VALUE), - StringIndexOutOfBoundsException) - << ("Should have thrown an StringIndexOutOfBoundsException"); + std::out_of_range) + << ("Should have thrown std::out_of_range"); ASSERT_THROW(handler.parse(url, "any", 10, Integer::MIN_VALUE + 1), - StringIndexOutOfBoundsException) - << ("Should have thrown an StringIndexOutOfBoundsException"); + std::out_of_range) + << ("Should have thrown std::out_of_range"); ASSERT_THROW( handler.parse(url, "any", Integer::MIN_VALUE, Integer::MIN_VALUE), - StringIndexOutOfBoundsException) - << ("Should have thrown an StringIndexOutOfBoundsException"); + std::out_of_range) + << ("Should have thrown std::out_of_range"); ASSERT_THROW(handler.parse(url, "any", Integer::MIN_VALUE, 2), - StringIndexOutOfBoundsException) - << ("Should have thrown an StringIndexOutOfBoundsException"); + std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(handler.parse(url, "any", -1, 2), - StringIndexOutOfBoundsException) - << ("Should have thrown an StringIndexOutOfBoundsException"); + ASSERT_THROW(handler.parse(url, "any", -1, 2), std::out_of_range) + << ("Should have thrown std::out_of_range"); - ASSERT_THROW(handler.parse(url, "any", -1, -1), SecurityException) + ASSERT_THROW(handler.parse(url, "any", -1, -1), std::logic_error) << ("Should have thrown an SecurityException"); } diff --git a/activemq-cpp/src/test/decaf/nio/BufferTest.cpp b/activemq-cpp/src/test/decaf/nio/BufferTest.cpp index 682af921f..cd79d8deb 100644 --- a/activemq-cpp/src/test/decaf/nio/BufferTest.cpp +++ b/activemq-cpp/src/test/decaf/nio/BufferTest.cpp @@ -17,11 +17,10 @@ #include #include +#include using namespace decaf; using namespace decaf::nio; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; class BufferTest : public ::testing::Test { @@ -166,7 +165,7 @@ TEST_F(BufferTest, testLimitInt) ASSERT_THROW(buffer->reset(), InvalidMarkException) << ("Should throw InvalidMarkException"); - ASSERT_THROW(buffer->limit(buffer->capacity() + 1), IllegalArgumentException) + ASSERT_THROW(buffer->limit(buffer->capacity() + 1), std::invalid_argument) << ("Should throw IllegalArgumentException"); } @@ -201,7 +200,7 @@ TEST_F(BufferTest, testPositionInt) { int oldPosition = buffer->position(); - ASSERT_THROW(buffer->position(buffer->limit() + 1), IllegalArgumentException) + ASSERT_THROW(buffer->position(buffer->limit() + 1), std::invalid_argument) << ("Should throw IllegalArgumentException"); buffer->mark(); diff --git a/activemq-cpp/src/test/decaf/security/MessageDigestTest.cpp b/activemq-cpp/src/test/decaf/security/MessageDigestTest.cpp index ca1af3ae3..31b30597a 100644 --- a/activemq-cpp/src/test/decaf/security/MessageDigestTest.cpp +++ b/activemq-cpp/src/test/decaf/security/MessageDigestTest.cpp @@ -19,8 +19,6 @@ #include #include -#include -#include #include #include #include @@ -28,7 +26,6 @@ using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::security; class MessageDigestTest : public ::testing::Test diff --git a/activemq-cpp/src/test/decaf/security/SecureRandomTest.cpp b/activemq-cpp/src/test/decaf/security/SecureRandomTest.cpp index 15d797bf3..95ec27404 100644 --- a/activemq-cpp/src/test/decaf/security/SecureRandomTest.cpp +++ b/activemq-cpp/src/test/decaf/security/SecureRandomTest.cpp @@ -21,13 +21,8 @@ #include -#include -#include - +#include using namespace std; -using namespace decaf; -using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::security; class SecureRandomTest : public ::testing::Test @@ -113,10 +108,10 @@ TEST_F(SecureRandomTest, testNextBytes2) ASSERT_TRUE(std::memcmp(buffer1, buffer3, 255) != 0); ASSERT_TRUE(std::memcmp(buffer2, buffer3, 255) != 0); - ASSERT_THROW(srng.nextBytes(NULL, 255), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(srng.nextBytes(NULL, 255), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(srng.nextBytes(buffer1, -1), IllegalArgumentException) + ASSERT_THROW(srng.nextBytes(buffer1, -1), std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -148,10 +143,10 @@ TEST_F(SecureRandomTest, testSetSeed2) SecureRandom srng; ASSERT_NO_THROW(srng.setSeed(seed, 8)); - ASSERT_THROW(srng.setSeed(NULL, 255), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(srng.setSeed(NULL, 255), std::logic_error) + << ("Should have thrown a std::logic_error"); - ASSERT_THROW(srng.setSeed(seed, -1), IllegalArgumentException) + ASSERT_THROW(srng.setSeed(seed, -1), std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } diff --git a/activemq-cpp/src/test/decaf/util/AbstractListTest.cpp b/activemq-cpp/src/test/decaf/util/AbstractListTest.cpp index dec68b4d0..bd8b1e776 100644 --- a/activemq-cpp/src/test/decaf/util/AbstractListTest.cpp +++ b/activemq-cpp/src/test/decaf/util/AbstractListTest.cpp @@ -17,15 +17,16 @@ #include +#include #include #include +#include #include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class AbstractListTest : public ::testing::Test { @@ -62,7 +63,10 @@ class SimpleList : public AbstractList { if (index < 0 || index >= (int)array.size()) { - throw IndexOutOfBoundsException(); + throw ::activemq::exceptions::OutOfRangeException( + __FILE__, + __LINE__, + "unit test simulated out of range"); } return this->array[index]; @@ -72,7 +76,10 @@ class SimpleList : public AbstractList { if (i < 0 || i > (int)array.size()) { - throw IndexOutOfBoundsException(); + throw ::activemq::exceptions::OutOfRangeException( + __FILE__, + __LINE__, + "unit test simulated out of range"); } this->array.insert(this->array.begin() + i, value); @@ -82,7 +89,10 @@ class SimpleList : public AbstractList { if (i < 0 || i >= (int)array.size()) { - throw IndexOutOfBoundsException(); + throw ::activemq::exceptions::OutOfRangeException( + __FILE__, + __LINE__, + "unit test simulated out of range"); } E oldValue = this->array[i]; @@ -120,7 +130,10 @@ class MockArrayList : public AbstractList { if (index < 0 || index >= (int)array.size()) { - throw IndexOutOfBoundsException(); + throw ::activemq::exceptions::OutOfRangeException( + __FILE__, + __LINE__, + "unit test simulated out of range"); } return this->array[index]; @@ -130,7 +143,10 @@ class MockArrayList : public AbstractList { if (i < 0 || i > (int)array.size()) { - throw IndexOutOfBoundsException(); + throw ::activemq::exceptions::OutOfRangeException( + __FILE__, + __LINE__, + "unit test simulated out of range"); } this->modCount += 10; @@ -141,7 +157,10 @@ class MockArrayList : public AbstractList { if (i < 0 || i >= (int)array.size()) { - throw IndexOutOfBoundsException(); + throw ::activemq::exceptions::OutOfRangeException( + __FILE__, + __LINE__, + "unit test simulated out of range"); } this->modCount++; @@ -210,7 +229,10 @@ class MockList : public AbstractList { if (index < 0 || index >= (int)array.size()) { - throw IndexOutOfBoundsException(); + throw ::activemq::exceptions::OutOfRangeException( + __FILE__, + __LINE__, + "unit test simulated out of range"); } return array[index]; @@ -299,9 +321,9 @@ TEST_F(AbstractListTest, testIteratorNext) try { it->next(); - FAIL() << ("Should throw NoSuchElementException"); + FAIL() << ("Should throw std::runtime_error"); } - catch (NoSuchElementException& cme) + catch (std::runtime_error& cme) { // expected } @@ -310,9 +332,9 @@ TEST_F(AbstractListTest, testIteratorNext) try { it->remove(); - FAIL() << ("Should throw ConcurrentModificationException"); + FAIL() << ("Should throw std::runtime_error"); } - catch (ConcurrentModificationException& cme) + catch (std::runtime_error& cme) { // expected } @@ -321,9 +343,9 @@ TEST_F(AbstractListTest, testIteratorNext) try { it->remove(); - FAIL() << ("Should throw IllegalStateException"); + FAIL() << ("Should throw std::logic_error"); } - catch (IllegalStateException& ise) + catch (std::logic_error& ise) { // expected } @@ -345,14 +367,14 @@ TEST_F(AbstractListTest, testRemove) { iter->remove(); } - catch (ConcurrentModificationException& e) + catch (std::runtime_error& e) { - FAIL() << ("Excepted to catch IllegalStateException not " - "ConcurrentModificationException"); + FAIL() << ("Excepted to catch std::logic_error not " + "std::runtime_error"); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { - // Excepted to catch IllegalStateException here + // Excepted to catch std::logic_error here } } @@ -409,7 +431,7 @@ TEST_F(AbstractListTest, testRemoveAt) list.removeAt(0); FAIL() << ("should throw UnsupportedOperationException"); } - catch (UnsupportedOperationException& e) + catch (std::logic_error& e) { // expected } @@ -419,7 +441,7 @@ TEST_F(AbstractListTest, testRemoveAt) list.set(0, 1); FAIL() << ("should throw UnsupportedOperationException"); } - catch (UnsupportedOperationException& e) + catch (std::logic_error& e) { // expected } diff --git a/activemq-cpp/src/test/decaf/util/AbstractSequentialListTest.cpp b/activemq-cpp/src/test/decaf/util/AbstractSequentialListTest.cpp index a2b6bbf6d..b0dfc6653 100644 --- a/activemq-cpp/src/test/decaf/util/AbstractSequentialListTest.cpp +++ b/activemq-cpp/src/test/decaf/util/AbstractSequentialListTest.cpp @@ -17,15 +17,16 @@ #include -#include +#include #include #include +#include +#include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class AbstractSequentialListTest : public ::testing::Test { @@ -84,47 +85,74 @@ class MockListIterator : public ListIterator virtual E next() { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } virtual bool hasNext() const { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } virtual void remove() { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } virtual void add(const E& e) { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } virtual void set(const E& e) { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } virtual bool hasPrevious() const { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } virtual E previous() { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } virtual int nextIndex() const { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } virtual int previousIndex() const { - throw UnsupportedOperationException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "UnsupportedOperationException"); } }; @@ -194,9 +222,9 @@ TEST_F(AbstractSequentialListTest, testGet) try { list.get(list.size()); - FAIL() << ("Should throw IndexOutOfBoundsException."); + FAIL() << ("Should throw std::out_of_range."); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // expected } @@ -204,9 +232,9 @@ TEST_F(AbstractSequentialListTest, testGet) try { list.get(-1); - FAIL() << ("Should throw IndexOutOfBoundsException."); + FAIL() << ("Should throw std::out_of_range."); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // expected } @@ -227,18 +255,18 @@ TEST_F(AbstractSequentialListTest, testRemove) try { list.removeAt(list.size()); - FAIL() << ("Should throw IndexOutOfBoundsException."); + FAIL() << ("Should throw std::out_of_range."); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // expected } try { list.removeAt(-1); - FAIL() << ("Should throw IndexOutOfBoundsException."); + FAIL() << ("Should throw std::out_of_range."); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // expected } @@ -250,7 +278,7 @@ TEST_F(AbstractSequentialListTest, testRemove) mylist.removeAt(0); FAIL() << ("Should throw UnsupportedOperationException."); } - catch (UnsupportedOperationException& e) + catch (activemq::exceptions::IllegalStateException& e) { // expected } @@ -264,9 +292,9 @@ TEST_F(AbstractSequentialListTest, testSet) try { list.set(0, 12); - FAIL() << ("should throw IndexOutOfBoundsException"); + FAIL() << ("should throw std::out_of_range"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // expected } diff --git a/activemq-cpp/src/test/decaf/util/ArrayListTest.cpp b/activemq-cpp/src/test/decaf/util/ArrayListTest.cpp index c8296dc90..50ccffed4 100644 --- a/activemq-cpp/src/test/decaf/util/ArrayListTest.cpp +++ b/activemq-cpp/src/test/decaf/util/ArrayListTest.cpp @@ -17,16 +17,17 @@ #include +#include #include -#include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using namespace activemq::exceptions; class ArrayListTest : public ::testing::Test { @@ -190,7 +191,7 @@ TEST_F(ArrayListTest, testAdd1) array1.add(25); ASSERT_TRUE(array1.get(0) == 25) << ("Failed to add Object"); - ASSERT_THROW(ArrayList(-1), IllegalArgumentException) + ASSERT_THROW(ArrayList(-1), std::invalid_argument) << ("Should throw an IllegalArgumentException"); } @@ -223,11 +224,11 @@ TEST_F(ArrayListTest, testAdd2) ASSERT_EQ(array.get(1), oldItem) << ("Should have returned the old item from slot 0"); - ASSERT_THROW(array.add(-1, 0), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(array.add(-1, 0), std::out_of_range) + << ("Should throw an std::out_of_range"); - ASSERT_THROW(array.add(array.size() + 1, 0), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(array.add(array.size() + 1, 0), std::out_of_range) + << ("Should throw an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -293,9 +294,8 @@ TEST_F(ArrayListTest, testAddAll1) TEST_F(ArrayListTest, testAddAll2) { StlList emptyCollection; - ASSERT_THROW(ArrayList().addAll(-1, emptyCollection), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(ArrayList().addAll(-1, emptyCollection), std::out_of_range) + << ("Should throw an std::out_of_range"); { std::string data[] = {"1", "2", "3", "4", "5", "6", "7", "8"}; @@ -368,11 +368,11 @@ TEST_F(ArrayListTest, testAddAll3) list.addAll(0, list); list.addAll(list.size(), list); - ASSERT_THROW(list.addAll(-1, list), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.addAll(-1, list), std::out_of_range) + << ("Should throw an std::out_of_range"); - ASSERT_THROW(list.addAll(list.size() + 1, list), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.addAll(list.size() + 1, list), std::out_of_range) + << ("Should throw an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -584,8 +584,8 @@ TEST_F(ArrayListTest, testGet) populate(mirror, SIZE); ASSERT_TRUE(array.get(22) == mirror[22]) << ("Returned incorrect element"); - ASSERT_THROW(array.get(9999), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(array.get(9999), std::out_of_range) + << ("Should throw an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -666,8 +666,8 @@ TEST_F(ArrayListTest, testRemoveAt) array.removeAt(10); ASSERT_EQ(-1, array.indexOf(10)) << ("Failed to remove element"); - ASSERT_THROW(array.removeAt(9999), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(array.removeAt(9999), std::out_of_range) + << ("Should throw an std::out_of_range"); ArrayList myArray(array); array.add(25, 9999); @@ -692,11 +692,11 @@ TEST_F(ArrayListTest, testRemoveAt) l.removeAt(0); l.removeAt(0); - ASSERT_THROW(l.removeAt(-1), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(l.removeAt(-1), std::out_of_range) + << ("Should throw an std::out_of_range"); - ASSERT_THROW(l.removeAt(0), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(l.removeAt(0), std::out_of_range) + << ("Should throw an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -717,11 +717,11 @@ TEST_F(ArrayListTest, testSet) array.set(0, 1); ASSERT_TRUE(array.get(0) == 1) << ("Failed to set object"); - ASSERT_THROW(array.set(-1, 10), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(array.set(-1, 10), std::out_of_range) + << ("Should throw an std::out_of_range"); - ASSERT_THROW(array.set(array.size(), 10), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(array.set(array.size(), 10), std::out_of_range) + << ("Should throw an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -801,7 +801,7 @@ TEST_F(ArrayListTest, testTrimToSize) array.trimToSize(); ASSERT_THROW(iter->next(), ConcurrentModificationException) - << ("Should throw an ConcurrentModificationException"); + << ("Should throw ConcurrentModificationException"); } //////////////////////////////////////////////////////////////////////////////// @@ -877,8 +877,8 @@ TEST_F(ArrayListTest, testListIterator1IndexOutOfBoundsException) ArrayList list; ASSERT_THROW(std::unique_ptr> it(list.listIterator(-1)), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -889,6 +889,6 @@ TEST_F(ArrayListTest, testListIterator2IndexOutOfBoundsException) list.add(2); ASSERT_THROW(std::unique_ptr> it(list.listIterator(100)), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw an std::out_of_range"); } diff --git a/activemq-cpp/src/test/decaf/util/ArraysTest.cpp b/activemq-cpp/src/test/decaf/util/ArraysTest.cpp index 82653b98d..1d27b4c3c 100644 --- a/activemq-cpp/src/test/decaf/util/ArraysTest.cpp +++ b/activemq-cpp/src/test/decaf/util/ArraysTest.cpp @@ -18,14 +18,14 @@ #include #include -#include #include +#include + using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class ArraysTest : public ::testing::Test { @@ -77,10 +77,10 @@ TEST_F(ArraysTest, testFill1) ASSERT_EQ(std::string("B"), stringArray[i]); } - ASSERT_THROW(Arrays::fill((bool*)NULL, -1, false), NullPointerException) - << ("Should throw a NullPointerException"); + ASSERT_THROW(Arrays::fill((bool*)NULL, -1, false), std::logic_error) + << ("Should throw std::logic_error"); - ASSERT_THROW(Arrays::fill(boolArray, -1, false), IllegalArgumentException) + ASSERT_THROW(Arrays::fill(boolArray, -1, false), std::invalid_argument) << ("Should throw a IllegalArgumentException"); } @@ -99,23 +99,21 @@ TEST_F(ArraysTest, testFill2) ASSERT_EQ(false, boolArray[i]); } - ASSERT_THROW(Arrays::fill((bool*)NULL, -1, 0, 1, false), - NullPointerException) - << ("Should throw a NullPointerException"); + ASSERT_THROW(Arrays::fill((bool*)NULL, -1, 0, 1, false), std::logic_error) + << ("Should throw std::logic_error"); - ASSERT_THROW(Arrays::fill(boolArray, -1, 0, 1, false), - IllegalArgumentException) + ASSERT_THROW(Arrays::fill(boolArray, -1, 0, 1, false), std::invalid_argument) << ("Should throw a IllegalArgumentException"); ASSERT_THROW(Arrays::fill(boolArray, SIZE, SIZE + 1, SIZE, false), - IllegalArgumentException) + std::invalid_argument) << ("Should throw a IllegalArgumentException"); ASSERT_THROW(Arrays::fill(boolArray, SIZE, -1, SIZE, false), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw a std::out_of_range"); ASSERT_THROW(Arrays::fill(boolArray, SIZE, 0, SIZE + 10, false), - IndexOutOfBoundsException) - << ("Should throw a IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw a std::out_of_range"); } diff --git a/activemq-cpp/src/test/decaf/util/BitSetTest.cpp b/activemq-cpp/src/test/decaf/util/BitSetTest.cpp index 19ef420e6..e6647fd5b 100644 --- a/activemq-cpp/src/test/decaf/util/BitSetTest.cpp +++ b/activemq-cpp/src/test/decaf/util/BitSetTest.cpp @@ -22,15 +22,12 @@ #include #include -#include -#include -#include +#include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class BitSetTest : public ::testing::Test { @@ -118,7 +115,7 @@ TEST_F(BitSetTest, testConstructorI) FAIL() << ("Failed to throw exception when creating a new BitSet with " "negative elements value"); } - catch (NegativeArraySizeException& e) + catch (std::runtime_error& e) { // Correct behavior } @@ -128,7 +125,7 @@ TEST_F(BitSetTest, testConstructorI) { BitSet bs(Integer::MAX_VALUE); } - catch (OutOfMemoryError& e) + catch (std::bad_alloc&) { // Ignore if no room for this size. } @@ -207,7 +204,7 @@ TEST_F(BitSetTest, testClearI) eightbs.clear(-1); FAIL() << ("Failed to throw expected out of bounds exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // Correct behaviour } @@ -243,9 +240,9 @@ TEST_F(BitSetTest, testClearI) try { bs1.clear(-1); - FAIL() << ("Should throw IndexOutOfBoundsException"); + FAIL() << ("Should throw std::out_of_range"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // expected } @@ -456,7 +453,7 @@ TEST_F(BitSetTest, testClearII) FAIL() << ("Test1: Attempt to flip with negative index " "CPPUNIT_FAILed to generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // excepted } @@ -467,7 +464,7 @@ TEST_F(BitSetTest, testClearII) FAIL() << ("Test2: Attempt to flip with negative index " "CPPUNIT_FAILed to generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // excepted } @@ -481,7 +478,7 @@ TEST_F(BitSetTest, testClearII) FAIL() << ("Test4: Attempt to flip with illegal args " "CPPUNIT_FAILed to generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // excepted } @@ -541,7 +538,7 @@ TEST_F(BitSetTest, testGetI) FAIL() << ("Attempt to get at negative index CPPUNIT_FAILed to " "generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // Correct behaviour } @@ -574,9 +571,9 @@ TEST_F(BitSetTest, testGetI) try { bs4.get(Integer::MIN_VALUE); - FAIL() << ("Should throw IndexOutOfBoundsException"); + FAIL() << ("Should throw std::out_of_range"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // expected } @@ -763,7 +760,7 @@ TEST_F(BitSetTest, testFlipI) FAIL() << ("Attempt to flip at negative index CPPUNIT_FAILed to " "generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // Correct behaviour } @@ -991,7 +988,7 @@ TEST_F(BitSetTest, testFlipII) FAIL() << ("Test1: Attempt to flip with negative index " "CPPUNIT_FAILed to generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // correct behavior } @@ -1002,7 +999,7 @@ TEST_F(BitSetTest, testFlipII) FAIL() << ("Test2: Attempt to flip with negative index " "CPPUNIT_FAILed to generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // correct behavior } @@ -1013,7 +1010,7 @@ TEST_F(BitSetTest, testFlipII) FAIL() << ("Test4: Attempt to flip with illegal args " "CPPUNIT_FAILed to generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // correct behavior } @@ -1033,7 +1030,7 @@ TEST_F(BitSetTest, testSetI) FAIL() << ("Attempt to set at negative index CPPUNIT_FAILed to " "generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // Correct behavior } @@ -1085,9 +1082,9 @@ TEST_F(BitSetTest, testSetIB) { BitSet bs; bs.set(-2147483648, false); - FAIL() << ("Should throw IndexOutOfBoundsException"); + FAIL() << ("Should throw std::out_of_range"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // expected } @@ -1258,7 +1255,7 @@ TEST_F(BitSetTest, testSetII) FAIL() << ("Test1: Attempt to flip with negative index " "CPPUNIT_FAILed to generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // Correct behavior } @@ -1269,7 +1266,7 @@ TEST_F(BitSetTest, testSetII) FAIL() << ("Test2: Attempt to flip with negative index " "CPPUNIT_FAILed to generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // Correct behavior } @@ -1283,7 +1280,7 @@ TEST_F(BitSetTest, testSetII) FAIL() << ("Test4: Attempt to flip with illegal args " "CPPUNIT_FAILed to generate exception"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // Correct behavior } @@ -1322,9 +1319,9 @@ TEST_F(BitSetTest, testNotModified) eightbs.clear(3, 3); ASSERT_TRUE(eightbs.get(3)) << ("Bit cleared incorrectly "); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { - FAIL() << ("Unexpected IndexOutOfBoundsException when pos1 ==pos2"); + FAIL() << ("Unexpected std::out_of_range when pos1 ==pos2"); } } @@ -1561,9 +1558,9 @@ TEST_F(BitSetTest, testNextSetBitI) try { bs.nextSetBit(-1); - FAIL() << ("Expected IndexOutOfBoundsException for negative index"); + FAIL() << ("Expected std::out_of_range for negative index"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // correct behavior } @@ -1646,9 +1643,9 @@ TEST_F(BitSetTest, testNextClearBitI) try { bs.nextClearBit(-1); - FAIL() << ("Expected IndexOutOfBoundsException for negative index"); + FAIL() << ("Expected std::out_of_range for negative index"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { // correct behavior } diff --git a/activemq-cpp/src/test/decaf/util/HashCodeTest.cpp b/activemq-cpp/src/test/decaf/util/HashCodeTest.cpp index 45dc489c0..38c4384be 100644 --- a/activemq-cpp/src/test/decaf/util/HashCodeTest.cpp +++ b/activemq-cpp/src/test/decaf/util/HashCodeTest.cpp @@ -22,7 +22,6 @@ using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; class HashCodeTest : public ::testing::Test diff --git a/activemq-cpp/src/test/decaf/util/HashMapTest.cpp b/activemq-cpp/src/test/decaf/util/HashMapTest.cpp index 07281fa76..a65236bd8 100644 --- a/activemq-cpp/src/test/decaf/util/HashMapTest.cpp +++ b/activemq-cpp/src/test/decaf/util/HashMapTest.cpp @@ -17,19 +17,20 @@ #include +#include #include -#include #include #include #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using namespace activemq::exceptions; class HashMapTest : public ::testing::Test { @@ -103,7 +104,7 @@ TEST_F(HashMapTest, testConstructorI) FAIL() << ("Should have thrown IllegalArgumentException for negative " "arg."); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { } @@ -127,7 +128,7 @@ TEST_F(HashMapTest, testConstructorIF) FAIL() << ("Should have thrown IllegalArgumentException for negative " "arg."); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { } @@ -514,13 +515,13 @@ TEST_F(HashMapTest, testRemove) ASSERT_NO_THROW(hashMap.remove(9)) << ("Remove returned incorrect value"); ASSERT_THROW(hashMap.get(9), NoSuchElementException) - << ("Should have thrown a NoSuchElementException on get of " + << ("Should have thrown NoSuchElementException on get of " "non-existent key."); ASSERT_TRUE(hashMap.size() == (size - 1)) << ("Failed to decrement size"); ASSERT_THROW(hashMap.remove(9), NoSuchElementException) - << ("Should have thrown a NoSuchElementException on remove of " + << ("Should have thrown NoSuchElementException on remove of " "non-existent key."); } { @@ -659,8 +660,8 @@ TEST_F(HashMapTest, testEntrySetIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.entrySet().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -672,8 +673,8 @@ TEST_F(HashMapTest, testEntrySetIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -695,8 +696,8 @@ TEST_F(HashMapTest, testKeySetIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.keySet().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -708,8 +709,8 @@ TEST_F(HashMapTest, testKeySetIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -731,8 +732,8 @@ TEST_F(HashMapTest, testValuesIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.values().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -744,6 +745,6 @@ TEST_F(HashMapTest, testValuesIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } diff --git a/activemq-cpp/src/test/decaf/util/HashSetTest.cpp b/activemq-cpp/src/test/decaf/util/HashSetTest.cpp index 3e32e29cf..f4c048328 100644 --- a/activemq-cpp/src/test/decaf/util/HashSetTest.cpp +++ b/activemq-cpp/src/test/decaf/util/HashSetTest.cpp @@ -18,19 +18,18 @@ #include #include -#include #include #include #include #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class HashSetTest : public ::testing::Test { @@ -121,7 +120,7 @@ void HashSetTest::testConstructorI() { HashSet set(-1); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { return; } @@ -139,7 +138,7 @@ void HashSetTest::testConstructorIF() { HashSet set(0, 0); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { return; } diff --git a/activemq-cpp/src/test/decaf/util/LRUCacheTest.cpp b/activemq-cpp/src/test/decaf/util/LRUCacheTest.cpp index 4c076e7b3..d32bf373e 100644 --- a/activemq-cpp/src/test/decaf/util/LRUCacheTest.cpp +++ b/activemq-cpp/src/test/decaf/util/LRUCacheTest.cpp @@ -20,13 +20,13 @@ #include #include +#include #include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class LRUCacheTest : public ::testing::Test { @@ -68,13 +68,13 @@ TEST_F(LRUCacheTest, testExceptions) LRUCache underTest(-1); FAIL() << ("Should have thrown an IllegalArgumentException"); } - catch (IllegalArgumentException& ex) + catch (std::invalid_argument& ex) { } LRUCache underTest(1000); - ASSERT_THROW(underTest.setMaxCacheSize(-1), IllegalArgumentException) + ASSERT_THROW(underTest.setMaxCacheSize(-1), std::invalid_argument) << ("Should throw an IllegalArgumentException"); } diff --git a/activemq-cpp/src/test/decaf/util/LinkedHashMapTest.cpp b/activemq-cpp/src/test/decaf/util/LinkedHashMapTest.cpp index 593efbd76..9c34558d5 100644 --- a/activemq-cpp/src/test/decaf/util/LinkedHashMapTest.cpp +++ b/activemq-cpp/src/test/decaf/util/LinkedHashMapTest.cpp @@ -17,19 +17,20 @@ #include +#include #include -#include #include #include #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using namespace activemq::exceptions; class LinkedHashMapTest : public ::testing::Test { @@ -92,7 +93,7 @@ TEST_F(LinkedHashMapTest, testConstructorI) FAIL() << ("Should have thrown IllegalArgumentException for negative " "arg."); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { } @@ -116,7 +117,7 @@ TEST_F(LinkedHashMapTest, testConstructorIF) FAIL() << ("Should have thrown IllegalArgumentException for negative " "arg."); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { } @@ -487,13 +488,13 @@ TEST_F(LinkedHashMapTest, testRemove) ASSERT_NO_THROW(hashMap.remove(9)) << ("Remove returned incorrect value"); ASSERT_THROW(hashMap.get(9), NoSuchElementException) - << ("Should have thrown a NoSuchElementException on get of " + << ("Should have thrown NoSuchElementException on get of " "non-existent key."); ASSERT_TRUE(hashMap.size() == (size - 1)) << ("Failed to decrement size"); ASSERT_THROW(hashMap.remove(9), NoSuchElementException) - << ("Should have thrown a NoSuchElementException on remove of " + << ("Should have thrown NoSuchElementException on remove of " "non-existent key."); } { @@ -632,8 +633,8 @@ TEST_F(LinkedHashMapTest, testEntrySetIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.entrySet().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -645,8 +646,8 @@ TEST_F(LinkedHashMapTest, testEntrySetIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -668,8 +669,8 @@ TEST_F(LinkedHashMapTest, testKeySetIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.keySet().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -681,8 +682,8 @@ TEST_F(LinkedHashMapTest, testKeySetIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -704,8 +705,8 @@ TEST_F(LinkedHashMapTest, testValuesIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.values().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -717,8 +718,8 @@ TEST_F(LinkedHashMapTest, testValuesIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/util/LinkedHashSetTest.cpp b/activemq-cpp/src/test/decaf/util/LinkedHashSetTest.cpp index 3373f6a9f..d75cb45de 100644 --- a/activemq-cpp/src/test/decaf/util/LinkedHashSetTest.cpp +++ b/activemq-cpp/src/test/decaf/util/LinkedHashSetTest.cpp @@ -18,19 +18,18 @@ #include #include -#include #include #include #include #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class LinkedHashSetTest : public ::testing::Test { @@ -91,7 +90,7 @@ TEST_F(LinkedHashSetTest, testConstructorI) { LinkedHashSet set(-1); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { return; } @@ -109,7 +108,7 @@ TEST_F(LinkedHashSetTest, testConstructorIF) { LinkedHashSet set(0, 0); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { return; } diff --git a/activemq-cpp/src/test/decaf/util/LinkedListTest.cpp b/activemq-cpp/src/test/decaf/util/LinkedListTest.cpp index 4e627dd8e..570d54c99 100644 --- a/activemq-cpp/src/test/decaf/util/LinkedListTest.cpp +++ b/activemq-cpp/src/test/decaf/util/LinkedListTest.cpp @@ -17,14 +17,15 @@ #include +#include #include #include #include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; +using namespace activemq::exceptions; class LinkedListTest : public ::testing::Test { @@ -143,11 +144,11 @@ TEST_F(LinkedListTest, testGet) ASSERT_EQ(SIZE / 2, list.get(SIZE / 2)); ASSERT_EQ(SIZE - 1, list.get(SIZE - 1)); - ASSERT_THROW(list.get(-1), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(list.get(-1), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(list.get(SIZE), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(list.get(SIZE), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -166,11 +167,11 @@ TEST_F(LinkedListTest, testSet) ASSERT_EQ(SIZE - 1, list.set(SIZE - 1, 42)); ASSERT_EQ(42, list.get(SIZE - 1)); - ASSERT_THROW(list.set(-1, 42), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(list.set(-1, 42), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(list.set(SIZE, 42), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(list.set(SIZE, 42), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -227,7 +228,7 @@ TEST_F(LinkedListTest, testGetFirst) LinkedList list; ASSERT_THROW(list.getFirst(), NoSuchElementException) - << ("Should have thrown an NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); populate(list, SIZE); ASSERT_EQ(0, list.getFirst()); @@ -239,7 +240,7 @@ TEST_F(LinkedListTest, testGetLast) LinkedList list; ASSERT_THROW(list.getLast(), NoSuchElementException) - << ("Should have thrown an NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); populate(list, SIZE); ASSERT_EQ(SIZE - 1, list.getLast()); @@ -309,11 +310,11 @@ TEST_F(LinkedListTest, testAdd2) ASSERT_EQ(168, list.getLast()); ASSERT_EQ(21, list.getFirst()); - ASSERT_THROW(list.add(-1, 12), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(list.add(-1, 12), std::out_of_range) + << ("Should have thrown an std::out_of_range"); - ASSERT_THROW(list.add(100, 12), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(list.add(100, 12), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -359,10 +360,10 @@ TEST_F(LinkedListTest, testAddAll1) TEST_F(LinkedListTest, testAddAll2) { LinkedList list; - ASSERT_THROW(list.addAll(-1, ArrayList()), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); - ASSERT_THROW(list.addAll(99, ArrayList()), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(list.addAll(-1, ArrayList()), std::out_of_range) + << ("Should have thrown an std::out_of_range"); + ASSERT_THROW(list.addAll(99, ArrayList()), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -406,9 +407,8 @@ TEST_F(LinkedListTest, testAddAll3) TEST_F(LinkedListTest, testAddAll4) { ArrayList emptyCollection; - ASSERT_THROW(ArrayList().addAll(-1, emptyCollection), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(ArrayList().addAll(-1, emptyCollection), std::out_of_range) + << ("Should throw an std::out_of_range"); { std::string data[] = {"1", "2", "3", "4", "5", "6", "7", "8"}; @@ -504,8 +504,8 @@ TEST_F(LinkedListTest, testRemoveAtIndex) list.removeAt(10); ASSERT_EQ(-1, list.indexOf(10)) << ("Failed to remove element"); - ASSERT_THROW(list.removeAt(999), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(list.removeAt(999), std::out_of_range) + << ("Should have thrown an std::out_of_range"); list.add(20, 0); list.removeAt(20); @@ -728,7 +728,7 @@ TEST_F(LinkedListTest, testQRemove) ASSERT_TRUE(list.size() == 0); ASSERT_THROW(list.remove(), NoSuchElementException) - << ("Should have thrown an NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); } //////////////////////////////////////////////////////////////////////////////// @@ -765,7 +765,7 @@ TEST_F(LinkedListTest, testElement) ASSERT_TRUE(list.size() == 0); ASSERT_THROW(list.element(), NoSuchElementException) - << ("Should have thrown an NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); } //////////////////////////////////////////////////////////////////////////////// @@ -814,7 +814,7 @@ TEST_F(LinkedListTest, testRemoveFirst) ASSERT_TRUE(list.size() == 0); ASSERT_THROW(list.removeFirst(), NoSuchElementException) - << ("Should have thrown an NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); } //////////////////////////////////////////////////////////////////////////////// @@ -831,7 +831,7 @@ TEST_F(LinkedListTest, testRemoveLast) ASSERT_TRUE(list.size() == 0); ASSERT_THROW(list.removeLast(), NoSuchElementException) - << ("Should have thrown an NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); } //////////////////////////////////////////////////////////////////////////////// @@ -922,7 +922,7 @@ TEST_F(LinkedListTest, testPop) ASSERT_TRUE(list.size() == 0); ASSERT_THROW(list.pop(), NoSuchElementException) - << ("Should have thrown an NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); } //////////////////////////////////////////////////////////////////////////////// @@ -948,8 +948,8 @@ TEST_F(LinkedListTest, testListIterator1IndexOutOfBoundsException) ASSERT_THROW( std::unique_ptr> it(list.listIterator(-1)), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -961,8 +961,8 @@ TEST_F(LinkedListTest, testListIterator2IndexOutOfBoundsException) ASSERT_THROW( std::unique_ptr> it(list.listIterator(100)), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -1093,24 +1093,24 @@ TEST_F(LinkedListTest, testListIterator2) } ASSERT_THROW(iter->next(), NoSuchElementException) - << ("Should have thrown a NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); ASSERT_EQ(list.size(), iter->nextIndex()); list.add(3); ASSERT_THROW(iter->next(), ConcurrentModificationException) - << ("Should have thrown a ConcurrentModificationException"); + << ("Should have thrown ConcurrentModificationException"); ASSERT_THROW(iter->add(42), ConcurrentModificationException) - << ("Should have thrown a ConcurrentModificationException"); + << ("Should have thrown ConcurrentModificationException"); ASSERT_THROW(iter->remove(), ConcurrentModificationException) - << ("Should have thrown a ConcurrentModificationException"); + << ("Should have thrown ConcurrentModificationException"); ASSERT_THROW(iter->previous(), ConcurrentModificationException) - << ("Should have thrown a ConcurrentModificationException"); + << ("Should have thrown ConcurrentModificationException"); iter.reset(list.listIterator()); - ASSERT_THROW(iter->previous(), IllegalStateException) - << ("Should have thrown a IllegalStateException"); - ASSERT_THROW(iter->set(42), IllegalStateException) - << ("Should have thrown a IllegalStateException"); + ASSERT_THROW(iter->previous(), std::logic_error) + << ("Should have thrown a std::logic_error"); + ASSERT_THROW(iter->set(42), std::logic_error) + << ("Should have thrown a std::logic_error"); int value = iter->next(); ASSERT_EQ(1, value) << ("Should have returned first element"); @@ -1124,7 +1124,7 @@ TEST_F(LinkedListTest, testListIterator3) ASSERT_EQ(-1, iter->previousIndex()); ASSERT_THROW(iter->next(), NoSuchElementException) - << ("Should have thrown a NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); ASSERT_TRUE(!iter->hasNext()) << ("hasNext() should be false"); iter->add(42); @@ -1176,13 +1176,13 @@ TEST_F(LinkedListTest, testDescendingIterator) iter.reset(list.descendingIterator()); ASSERT_EQ(5, list.size()); - ASSERT_THROW(iter->remove(), IllegalStateException) - << ("Should have thrown a IllegalStateException"); + ASSERT_THROW(iter->remove(), std::logic_error) + << ("Should have thrown a std::logic_error"); list.add(5); ASSERT_THROW(iter->remove(), ConcurrentModificationException) - << ("Should have thrown a ConcurrentModificationException"); + << ("Should have thrown ConcurrentModificationException"); iter.reset(list.descendingIterator()); ASSERT_EQ(5, iter->next()); @@ -1197,7 +1197,7 @@ TEST_F(LinkedListTest, testDescendingIterator) ASSERT_TRUE(!iter->hasNext()); ASSERT_THROW(iter->next(), NoSuchElementException) - << ("Should have thrown a NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/util/ListTest.cpp b/activemq-cpp/src/test/decaf/util/ListTest.cpp index 9548c18aa..222f58829 100644 --- a/activemq-cpp/src/test/decaf/util/ListTest.cpp +++ b/activemq-cpp/src/test/decaf/util/ListTest.cpp @@ -27,7 +27,6 @@ using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class ListTest : public ::testing::Test { @@ -406,9 +405,8 @@ TEST_F(ListTest, testAdd2) ASSERT_TRUE(list.get(4) == "fred"); ASSERT_TRUE(list.get(5) == "bob"); - ASSERT_THROW(list.add(list.size() + 1, "bob"), - decaf::lang::exceptions::IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.add(list.size() + 1, "bob"), std::out_of_range) + << ("Should throw an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -440,11 +438,11 @@ TEST_F(ListTest, testAdd3) ASSERT_EQ(array.get(1), oldItem) << ("Should have returned the old item from slot 0"); - ASSERT_THROW(array.add(-1, 0), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(array.add(-1, 0), std::out_of_range) + << ("Should throw an std::out_of_range"); - ASSERT_THROW(array.add(array.size() + 1, 0), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(array.add(array.size() + 1, 0), std::out_of_range) + << ("Should throw an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -482,9 +480,8 @@ TEST_F(ListTest, testAddAll1) TEST_F(ListTest, testAddAll2) { StlList emptyCollection; - ASSERT_THROW(StlList().addAll(-1, emptyCollection), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(StlList().addAll(-1, emptyCollection), std::out_of_range) + << ("Should throw an std::out_of_range"); { std::string data[] = {"1", "2", "3", "4", "5", "6", "7", "8"}; @@ -557,11 +554,11 @@ TEST_F(ListTest, testAddAll3) list.addAll(0, list); list.addAll(list.size(), list); - ASSERT_THROW(list.addAll(-1, list), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.addAll(-1, list), std::out_of_range) + << ("Should throw an std::out_of_range"); - ASSERT_THROW(list.addAll(list.size() + 1, list), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.addAll(list.size() + 1, list), std::out_of_range) + << ("Should throw an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -747,9 +744,8 @@ TEST_F(ListTest, testRemove2) ASSERT_TRUE(list.removeAt(2) == "mike"); ASSERT_TRUE(list.get(2) == "larry"); - ASSERT_THROW(list.removeAt(list.size() + 1), - decaf::lang::exceptions::IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.removeAt(list.size() + 1), std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -788,8 +784,8 @@ TEST_F(ListTest, testRemoveAt) array.removeAt(10); ASSERT_EQ(-1, array.indexOf(10)) << ("Failed to remove element"); - ASSERT_THROW(array.removeAt(9999), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(array.removeAt(9999), std::out_of_range) + << ("Should throw an std::out_of_range"); StlList myArray(array); array.add(25, 9999); @@ -814,11 +810,11 @@ TEST_F(ListTest, testRemoveAt) l.removeAt(0); l.removeAt(0); - ASSERT_THROW(l.removeAt(-1), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(l.removeAt(-1), std::out_of_range) + << ("Should throw an std::out_of_range"); - ASSERT_THROW(l.removeAt(0), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(l.removeAt(0), std::out_of_range) + << ("Should throw an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -878,8 +874,8 @@ TEST_F(ListTest, testListIterator1IndexOutOfBoundsException) StlList list; ASSERT_THROW(std::unique_ptr> it(list.listIterator(-1)), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -890,6 +886,6 @@ TEST_F(ListTest, testListIterator2IndexOutOfBoundsException) list.add(2); ASSERT_THROW(std::unique_ptr> it(list.listIterator(100)), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw an std::out_of_range"); } diff --git a/activemq-cpp/src/test/decaf/util/PriorityQueueTest.cpp b/activemq-cpp/src/test/decaf/util/PriorityQueueTest.cpp index 077d14a7e..8ccc66589 100644 --- a/activemq-cpp/src/test/decaf/util/PriorityQueueTest.cpp +++ b/activemq-cpp/src/test/decaf/util/PriorityQueueTest.cpp @@ -17,18 +17,20 @@ #include +#include #include #include #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::util; +using namespace activemq::exceptions; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class PriorityQueueTest : public ::testing::Test { @@ -168,8 +170,8 @@ TEST_F(PriorityQueueTest, testOfferString) std::string result; ASSERT_TRUE(0 == queue.size()); - ASSERT_THROW(queue.remove(), decaf::util::NoSuchElementException) - << ("Should Throw a NoSuchElementException"); + ASSERT_THROW(queue.remove(), InterruptedException) + << ("Should Throw InterruptedException"); } //////////////////////////////////////////////////////////////////////////////// @@ -394,7 +396,7 @@ TEST_F(PriorityQueueTest, testIterator) } ASSERT_THROW(iter->next(), NoSuchElementException) - << ("Should Throw a NoSuchElementException"); + << ("Should Throw NoSuchElementException"); std::sort(result.begin(), result.end()); @@ -411,11 +413,11 @@ TEST_F(PriorityQueueTest, testIteratorEmpty) std::unique_ptr> iter(intQueue.iterator()); ASSERT_THROW(iter->next(), NoSuchElementException) - << ("Should Throw a NoSuchElementException"); + << ("Should Throw NoSuchElementException"); iter.reset(intQueue.iterator()); - ASSERT_THROW(iter->remove(), IllegalStateException) - << ("Should Throw a IllegalStateException"); + ASSERT_THROW(iter->remove(), std::logic_error) + << ("Should Throw a std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -426,13 +428,13 @@ TEST_F(PriorityQueueTest, testIteratorOutOfBounds) std::unique_ptr> iter(intQueue.iterator()); iter->next(); ASSERT_THROW(iter->next(), NoSuchElementException) - << ("Should Throw a NoSuchElementException"); + << ("Should Throw NoSuchElementException"); iter.reset(intQueue.iterator()); iter->next(); iter->remove(); ASSERT_THROW(iter->next(), NoSuchElementException) - << ("Should Throw a NoSuchElementException"); + << ("Should Throw NoSuchElementException"); } //////////////////////////////////////////////////////////////////////////////// @@ -477,7 +479,7 @@ TEST_F(PriorityQueueTest, testIteratorRemove) std::unique_ptr> const_iter(constQueue.iterator()); const_iter->next(); - ASSERT_THROW(const_iter->remove(), UnsupportedOperationException) + ASSERT_THROW(const_iter->remove(), std::logic_error) << ("Should Throw a UnsupportedOperationException"); } @@ -492,11 +494,11 @@ TEST_F(PriorityQueueTest, testIteratorRemoveIllegalState) } std::unique_ptr> iter(intQueue.iterator()); ASSERT_TRUE(iter.get() != NULL); - ASSERT_THROW(iter->remove(), IllegalStateException) - << ("Should Throw a IllegalStateException"); + ASSERT_THROW(iter->remove(), std::logic_error) + << ("Should Throw a std::logic_error"); iter->next(); iter->remove(); - ASSERT_THROW(iter->remove(), IllegalStateException) - << ("Should Throw a IllegalStateException"); + ASSERT_THROW(iter->remove(), std::logic_error) + << ("Should Throw a std::logic_error"); } diff --git a/activemq-cpp/src/test/decaf/util/PropertiesTest.cpp b/activemq-cpp/src/test/decaf/util/PropertiesTest.cpp index b3a8bf7bc..2cc739e0f 100644 --- a/activemq-cpp/src/test/decaf/util/PropertiesTest.cpp +++ b/activemq-cpp/src/test/decaf/util/PropertiesTest.cpp @@ -17,6 +17,8 @@ #include +#include + #include #include #include @@ -226,13 +228,11 @@ TEST_F(PropertiesTest, testLoadNPE) decaf::io::InputStream* nullStream = NULL; decaf::io::Reader* nullReader = NULL; - ASSERT_THROW(properties.load(nullStream), - decaf::lang::exceptions::NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(properties.load(nullStream), std::logic_error) + << ("Should have thrown std::logic_error"); - ASSERT_THROW(properties.load(nullReader), - decaf::lang::exceptions::NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(properties.load(nullReader), std::logic_error) + << ("Should have thrown std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/util/StlMapTest.cpp b/activemq-cpp/src/test/decaf/util/StlMapTest.cpp index 677bb6c39..b2f9b796d 100644 --- a/activemq-cpp/src/test/decaf/util/StlMapTest.cpp +++ b/activemq-cpp/src/test/decaf/util/StlMapTest.cpp @@ -17,19 +17,19 @@ #include +#include #include -#include -#include #include #include #include +#include #include using namespace std; using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using namespace activemq::exceptions; class StlMapTest : public ::testing::Test { @@ -57,8 +57,8 @@ TEST_F(StlMapTest, testConstructor) ASSERT_TRUE(map1.isEmpty()); ASSERT_TRUE(map1.size() == 0); - ASSERT_THROW(map1.get("TEST"), decaf::util::NoSuchElementException) - << ("Should Throw a NoSuchElementException"); + ASSERT_THROW(map1.get("TEST"), NoSuchElementException) + << ("Should Throw NoSuchElementException"); HashMap srcMap; srcMap.put("A", 1); @@ -187,7 +187,7 @@ TEST_F(StlMapTest, testGet) boolMap.get("mike"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } } @@ -243,8 +243,8 @@ TEST_F(StlMapTest, testRemove) ASSERT_TRUE(boolMap.remove("fred") == true); ASSERT_TRUE(boolMap.containsKey("fred") == false); - ASSERT_THROW(boolMap.remove("fred"), decaf::util::NoSuchElementException) - << ("Should throw a NoSuchElementException"); + ASSERT_THROW(boolMap.remove("fred"), NoSuchElementException) + << ("Should throw NoSuchElementException"); } //////////////////////////////////////////////////////////////////////////////// @@ -390,8 +390,8 @@ TEST_F(StlMapTest, testEntrySetIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.entrySet().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -403,8 +403,8 @@ TEST_F(StlMapTest, testEntrySetIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -426,8 +426,8 @@ TEST_F(StlMapTest, testKeySetIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.keySet().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -439,8 +439,8 @@ TEST_F(StlMapTest, testKeySetIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -462,8 +462,8 @@ TEST_F(StlMapTest, testValuesIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.values().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -475,6 +475,6 @@ TEST_F(StlMapTest, testValuesIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } diff --git a/activemq-cpp/src/test/decaf/util/StringTokenizerTest.cpp b/activemq-cpp/src/test/decaf/util/StringTokenizerTest.cpp index 6ce288dc1..a2d65ceb6 100644 --- a/activemq-cpp/src/test/decaf/util/StringTokenizerTest.cpp +++ b/activemq-cpp/src/test/decaf/util/StringTokenizerTest.cpp @@ -57,7 +57,7 @@ TEST_F(StringTokenizerTest, test) tokenizer3.nextToken(); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException ex) + catch (std::runtime_error ex) { ASSERT_TRUE(true); } diff --git a/activemq-cpp/src/test/decaf/util/TimerTest.cpp b/activemq-cpp/src/test/decaf/util/TimerTest.cpp index d6fe9f455..5ed77cf19 100644 --- a/activemq-cpp/src/test/decaf/util/TimerTest.cpp +++ b/activemq-cpp/src/test/decaf/util/TimerTest.cpp @@ -17,21 +17,21 @@ #include +#include #include #include #include #include #include -#include #include #include #include #include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::atomic; @@ -172,7 +172,7 @@ namespace util { Thread::sleep(200); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -235,7 +235,7 @@ namespace util { Thread::sleep(200); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -270,7 +270,7 @@ TEST_F(TimerTest, testConstructor) { this->gsync.wait(2000000); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -287,16 +287,16 @@ TEST_F(TimerTest, testCancel) std::unique_ptr t; TimerTaskReport report; - // Ensure a task throws an IllegalStateException after cancelled + // Ensure a task throws std::logic_error after cancelled t.reset(new Timer()); TimerTestTask* testTask = new TimerTestTask(&report, &this->timerCounter, &this->gsync); t->cancel(); - ASSERT_THROW(t->schedule(testTask, 100, 200), IllegalStateException) + ASSERT_THROW(t->schedule(testTask, 100, 200), std::logic_error) << ("Scheduling a task after Timer.cancel() should throw " - "IllegalStateException"); + "std::logic_error"); // unscheduled tasks must be deleted delete testTask; @@ -311,7 +311,7 @@ TEST_F(TimerTest, testCancel) { this->gsync.wait(1000); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -326,7 +326,7 @@ TEST_F(TimerTest, testCancel) { this->gsync.wait(500); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -345,7 +345,7 @@ TEST_F(TimerTest, testCancel) { this->gsync.wait(500); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -363,7 +363,7 @@ TEST_F(TimerTest, testCancel) { this->gsync.wait(500); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -391,7 +391,7 @@ TEST_F(TimerTest, testCancel) this->gsync.wait(500); this->gsync.wait(500); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -406,7 +406,7 @@ TEST_F(TimerTest, testCancel) { Thread::sleep(200); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -449,7 +449,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); TimerTestTask* testTask = new TimerTestTask(&this->timerCounter, &this->gsync); @@ -461,7 +461,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date) { t->schedule(testTask, d); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; // unscheduled tasks must be deleted @@ -471,7 +471,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date) ASSERT_TRUE(exception == true) << ("Scheduling a task after Timer.cancel() should throw exception"); - // Ensure a Timer throws an IllegalStateException if task already cancelled + // Ensure a Timer throws std::logic_error if task already cancelled t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); d.setTime(System::currentTimeMillis() + 100); @@ -481,7 +481,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date) { t->schedule(testTask, d); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; // unscheduled tasks must be deleted @@ -492,7 +492,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date) << ("Scheduling a task after cancelling it should throw exception"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if delay is negative + // Ensure a Timer throws an std::invalid_argument if delay is negative t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); d.setTime(-100); @@ -501,7 +501,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date) { t->schedule(testTask, d); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; // unscheduled tasks must be deleted @@ -511,7 +511,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date) "should throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws a NullPointerException if the task is null + // Ensure a Timer throws a std::logic_error if the task is null t.reset(new Timer()); exception = false; d.setTime(System::currentTimeMillis() + 100); @@ -519,12 +519,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date) { t->schedule(NULL, d); } - catch (NullPointerException& e) + catch (std::logic_error& e) { exception = true; } ASSERT_TRUE(exception == true) - << ("Scheduling a null task should throw NullPointerException"); + << ("Scheduling a null task should throw std::logic_error"); t->cancel(); // Ensure proper sequence of exceptions @@ -535,12 +535,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date) { t->schedule(NULL, d); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception == true) << ("Scheduling a null task with negative date should throw " @@ -556,7 +556,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date) { Thread::sleep(400); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } @@ -586,7 +586,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date) { Thread::sleep(400); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } @@ -603,7 +603,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date2) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); Pointer testTask( new TimerTestTask(&this->timerCounter, &this->gsync)); @@ -615,7 +615,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date2) { t->schedule(testTask, d); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; } @@ -623,7 +623,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date2) ASSERT_TRUE(exception == true) << ("Scheduling a task after Timer.cancel() should throw exception"); - // Ensure a Timer throws an IllegalStateException if task already cancelled + // Ensure a Timer throws std::logic_error if task already cancelled t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); d.setTime(System::currentTimeMillis() + 100); @@ -633,7 +633,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date2) { t->schedule(testTask, d); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; } @@ -642,7 +642,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date2) << ("Scheduling a task after cancelling it should throw exception"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if delay is negative + // Ensure a Timer throws an std::invalid_argument if delay is negative t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); d.setTime(-100); @@ -651,7 +651,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date2) { t->schedule(testTask, d); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; } @@ -659,7 +659,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date2) "should throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws a NullPointerException if the task is null + // Ensure a Timer throws a std::logic_error if the task is null t.reset(new Timer()); exception = false; d.setTime(System::currentTimeMillis() + 100); @@ -667,12 +667,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date2) { t->schedule(NULL, d); } - catch (NullPointerException& e) + catch (std::logic_error& e) { exception = true; } ASSERT_TRUE(exception == true) - << ("Scheduling a null task should throw NullPointerException"); + << ("Scheduling a null task should throw std::logic_error"); t->cancel(); // Ensure proper sequence of exceptions @@ -683,12 +683,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date2) { t->schedule(NULL, d); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception == true) << ("Scheduling a null task with negative date should throw " @@ -705,7 +705,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date2) { Thread::sleep(500); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } @@ -735,7 +735,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date2) { Thread::sleep(400); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } @@ -752,7 +752,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); TimerTestTask* testTask = new TimerTestTask(&this->timerCounter, &this->gsync); @@ -762,7 +762,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long) { t->schedule(testTask, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; // unscheduled tasks must be deleted @@ -771,7 +771,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long) ASSERT_TRUE(exception == true) << ("Scheduling a task after Timer.cancel() should throw exception"); - // Ensure a Timer throws an IllegalStateException if task already cancelled + // Ensure a Timer throws std::logic_error if task already cancelled t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); testTask->cancel(); @@ -780,7 +780,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long) { t->schedule(testTask, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; // unscheduled tasks must be deleted @@ -790,7 +790,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long) << ("Scheduling a task after cancelling it should throw exception"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if delay is negative + // Ensure a Timer throws an std::invalid_argument if delay is negative t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); exception = false; @@ -798,7 +798,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long) { t->schedule(testTask, -100); } - catch (IllegalArgumentException e) + catch (std::invalid_argument e) { exception = true; // unscheduled tasks must be deleted @@ -808,19 +808,19 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long) "should throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws a NullPointerException if the task is null + // Ensure a Timer throws a std::logic_error if the task is null t.reset(new Timer()); exception = false; try { t->schedule(NULL, 10); } - catch (NullPointerException e) + catch (std::logic_error e) { exception = true; } ASSERT_TRUE(exception == true) - << ("Scheduling a null task should throw NullPointerException"); + << ("Scheduling a null task should throw std::logic_error"); t->cancel(); // Ensure proper sequence of exceptions @@ -830,12 +830,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long) { t->schedule(NULL, -10); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception == true) << ("Scheduling a null task with negative delays should throw " @@ -850,7 +850,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long) { Thread::sleep(400); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(1 == report.wasRun.get()) @@ -875,7 +875,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long) { Thread::sleep(400); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } @@ -892,7 +892,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long2) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); Pointer testTask( new TimerTestTask(&this->timerCounter, &this->gsync)); @@ -902,14 +902,14 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long2) { t->schedule(testTask, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; } ASSERT_TRUE(exception == true) << ("Scheduling a task after Timer.cancel() should throw exception"); - // Ensure a Timer throws an IllegalStateException if task already cancelled + // Ensure a Timer throws std::logic_error if task already cancelled t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); testTask->cancel(); @@ -918,7 +918,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long2) { t->schedule(testTask, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; } @@ -926,7 +926,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long2) << ("Scheduling a task after cancelling it should throw exception"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if delay is negative + // Ensure a Timer throws an std::invalid_argument if delay is negative t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); exception = false; @@ -934,7 +934,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long2) { t->schedule(testTask, -100); } - catch (IllegalArgumentException e) + catch (std::invalid_argument e) { exception = true; } @@ -942,19 +942,19 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long2) "should throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws a NullPointerException if the task is null + // Ensure a Timer throws a std::logic_error if the task is null t.reset(new Timer()); exception = false; try { t->schedule(NULL, 10); } - catch (NullPointerException e) + catch (std::logic_error e) { exception = true; } ASSERT_TRUE(exception == true) - << ("Scheduling a null task should throw NullPointerException"); + << ("Scheduling a null task should throw std::logic_error"); t->cancel(); // Ensure proper sequence of exceptions @@ -964,12 +964,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long2) { t->schedule(NULL, -10); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception == true) << ("Scheduling a null task with negative delays should throw " @@ -985,7 +985,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long2) { Thread::sleep(400); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(1 == report.wasRun.get()) @@ -1010,7 +1010,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long2) { Thread::sleep(400); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } @@ -1027,7 +1027,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); TimerTestTask* testTask = new TimerTestTask(&this->timerCounter, &this->gsync); @@ -1037,7 +1037,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) { t->schedule(testTask, 100, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; // unscheduled tasks must be deleted @@ -1046,7 +1046,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) ASSERT_TRUE(exception) << ("Scheduling a task after Timer.cancel() should " "throw exception"); - // Ensure a Timer throws an IllegalStateException if task already cancelled + // Ensure a Timer throws std::logic_error if task already cancelled t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); testTask->cancel(); @@ -1055,7 +1055,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) { t->schedule(testTask, 100, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; // unscheduled tasks must be deleted @@ -1065,7 +1065,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) "throw exception"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if delay is + // Ensure a Timer throws an std::invalid_argument if delay is // negative t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); @@ -1074,7 +1074,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) { t->schedule(testTask, -100, 100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; // unscheduled tasks must be deleted @@ -1084,7 +1084,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if period is negative + // Ensure a Timer throws an std::invalid_argument if period is negative t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); exception = false; @@ -1092,7 +1092,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) { t->schedule(testTask, 100, -100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; // unscheduled tasks must be deleted @@ -1102,7 +1102,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if period is zero + // Ensure a Timer throws an std::invalid_argument if period is zero t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); exception = false; @@ -1110,7 +1110,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) { t->schedule(testTask, 100, 0); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; // unscheduled tasks must be deleted @@ -1120,19 +1120,19 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) "IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws a NullPointerException if the task is null + // Ensure a Timer throws a std::logic_error if the task is null t.reset(new Timer()); exception = false; try { t->schedule(NULL, 10, 10); } - catch (NullPointerException& e) + catch (std::logic_error& e) { exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task should throw " - "NullPointerException"); + "std::logic_error"); t->cancel(); // Ensure proper sequence of exceptions @@ -1142,12 +1142,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) { t->schedule(NULL, -10, -10); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task with negative delays " "should throw IllegalArgumentException first"); @@ -1161,7 +1161,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) { Thread::sleep(1000); // Increased for macOS CI scheduling latency } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(report.wasRun.get() >= 2) @@ -1188,7 +1188,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long) Thread::sleep(2000); // Allowed more room for error (increased for // macOS CI scheduling latency) } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(timerCounter.get() >= 24) @@ -1204,7 +1204,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); Pointer testTask( new TimerTestTask(&this->timerCounter, &this->gsync)); @@ -1214,14 +1214,14 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) { t->schedule(testTask, 100, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; } ASSERT_TRUE(exception) << ("Scheduling a task after Timer.cancel() should " "throw exception"); - // Ensure a Timer throws an IllegalStateException if task already cancelled + // Ensure a Timer throws std::logic_error if task already cancelled t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); testTask->cancel(); @@ -1230,7 +1230,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) { t->schedule(testTask, 100, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; } @@ -1238,7 +1238,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) "throw exception"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if delay is + // Ensure a Timer throws an std::invalid_argument if delay is // negative t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); @@ -1247,7 +1247,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) { t->schedule(testTask, -100, 100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; } @@ -1255,7 +1255,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if period is negative + // Ensure a Timer throws an std::invalid_argument if period is negative t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); exception = false; @@ -1263,7 +1263,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) { t->schedule(testTask, 100, -100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; } @@ -1271,7 +1271,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if period is zero + // Ensure a Timer throws an std::invalid_argument if period is zero t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); exception = false; @@ -1279,7 +1279,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) { t->schedule(testTask, 100, 0); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; } @@ -1287,19 +1287,19 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) "IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws a NullPointerException if the task is null + // Ensure a Timer throws a std::logic_error if the task is null t.reset(new Timer()); exception = false; try { t->schedule(NULL, 10, 10); } - catch (NullPointerException& e) + catch (std::logic_error& e) { exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task should throw " - "NullPointerException"); + "std::logic_error"); t->cancel(); // Ensure proper sequence of exceptions @@ -1309,12 +1309,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) { t->schedule(NULL, -10, -10); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task with negative delays " "should throw IllegalArgumentException first"); @@ -1329,7 +1329,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) { Thread::sleep(1000); // Increased for macOS CI scheduling latency } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(report.wasRun.get() >= 2) @@ -1356,7 +1356,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Long_Long2) Thread::sleep(2000); // Allowed more room for error (increased for // macOS CI scheduling latency) } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(timerCounter.get() >= 24) @@ -1372,7 +1372,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); TimerTestTask* testTask = new TimerTestTask(&this->timerCounter, &this->gsync); @@ -1383,7 +1383,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) { t->schedule(testTask, d, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; // unscheduled tasks must be deleted @@ -1392,7 +1392,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) ASSERT_TRUE(exception) << ("Scheduling a task after Timer.cancel() should " "throw exception"); - // Ensure a Timer throws an IllegalStateException if task already cancelled + // Ensure a Timer throws std::logic_error if task already cancelled t.reset(new Timer()); d.setTime(System::currentTimeMillis() + 100); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); @@ -1402,7 +1402,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) { t->schedule(testTask, d, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; // unscheduled tasks must be deleted @@ -1412,7 +1412,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) "throw exception"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if delay is + // Ensure a Timer throws an std::invalid_argument if delay is // negative t.reset(new Timer()); d.setTime(-100); @@ -1422,7 +1422,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) { t->schedule(testTask, d, 100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; // unscheduled tasks must be deleted @@ -1432,7 +1432,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if period is + // Ensure a Timer throws an std::invalid_argument if period is // negative t.reset(new Timer()); d.setTime(System::currentTimeMillis() + 100); @@ -1442,7 +1442,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) { t->schedule(testTask, d, -100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; // unscheduled tasks must be deleted @@ -1452,7 +1452,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws a NullPointerException if the task is null + // Ensure a Timer throws a std::logic_error if the task is null t.reset(new Timer()); d.setTime(System::currentTimeMillis() + 100); exception = false; @@ -1460,12 +1460,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) { t->schedule(NULL, d, 10); } - catch (NullPointerException& e) + catch (std::logic_error& e) { exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task should throw " - "NullPointerException"); + "std::logic_error"); t->cancel(); // Ensure proper sequence of exceptions @@ -1476,12 +1476,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) { t->schedule(NULL, d, 10); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task with negative dates " "should throw IllegalArgumentException first"); @@ -1496,7 +1496,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) { Thread::sleep(800); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(report.wasRun.get() >= 2) @@ -1527,7 +1527,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long) { Thread::sleep(3000); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(timerCounter.get() >= 24) @@ -1543,7 +1543,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); Pointer testTask( new TimerTestTask(&this->timerCounter, &this->gsync)); @@ -1554,14 +1554,14 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) { t->schedule(testTask, d, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; } ASSERT_TRUE(exception) << ("Scheduling a task after Timer.cancel() should " "throw exception"); - // Ensure a Timer throws an IllegalStateException if task already cancelled + // Ensure a Timer throws std::logic_error if task already cancelled t.reset(new Timer()); d.setTime(System::currentTimeMillis() + 100); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); @@ -1571,7 +1571,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) { t->schedule(testTask, d, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; } @@ -1579,7 +1579,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) "throw exception"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if delay is + // Ensure a Timer throws an std::invalid_argument if delay is // negative t.reset(new Timer()); d.setTime(-100); @@ -1589,7 +1589,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) { t->schedule(testTask, d, 100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; } @@ -1597,7 +1597,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if period is + // Ensure a Timer throws an std::invalid_argument if period is // negative t.reset(new Timer()); d.setTime(System::currentTimeMillis() + 100); @@ -1607,7 +1607,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) { t->schedule(testTask, d, -100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; } @@ -1615,7 +1615,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws a NullPointerException if the task is null + // Ensure a Timer throws a std::logic_error if the task is null t.reset(new Timer()); d.setTime(System::currentTimeMillis() + 100); exception = false; @@ -1623,12 +1623,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) { t->schedule(NULL, d, 10); } - catch (NullPointerException& e) + catch (std::logic_error& e) { exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task should throw " - "NullPointerException"); + "std::logic_error"); t->cancel(); // Ensure proper sequence of exceptions @@ -1639,12 +1639,12 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) { t->schedule(NULL, d, 10); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task with negative dates " "should throw IllegalArgumentException first"); @@ -1660,7 +1660,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) { Thread::sleep(800); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(report.wasRun.get() >= 2) @@ -1691,7 +1691,7 @@ TEST_F(TimerTest, testSchedule_TimerTask_Date_Long2) { Thread::sleep(3000); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(timerCounter.get() >= 24) @@ -1707,7 +1707,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); TimerTestTask* testTask = new TimerTestTask(&this->timerCounter, &this->gsync); @@ -1717,7 +1717,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long) { t->scheduleAtFixedRate(testTask, 100, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; // unscheduled tasks must be deleted @@ -1726,7 +1726,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long) ASSERT_TRUE(exception) << ("scheduleAtFixedRate after Timer.cancel() " "should throw exception"); - // Ensure a Timer throws an IllegalArgumentException if delay is negative + // Ensure a Timer throws an std::invalid_argument if delay is negative t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); exception = false; @@ -1734,7 +1734,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long) { t->scheduleAtFixedRate(testTask, -100, 100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; // unscheduled tasks must be deleted @@ -1744,7 +1744,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if period is negative + // Ensure a Timer throws an std::invalid_argument if period is negative t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); exception = false; @@ -1752,7 +1752,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long) { t->scheduleAtFixedRate(testTask, 100, -100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; // unscheduled tasks must be deleted @@ -1770,7 +1770,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long) { Thread::sleep(400); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(report.wasRun.get() >= 2) @@ -1790,7 +1790,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long) { Thread::sleep(1000); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } long long lastDelta = report.lastDelta; @@ -1806,7 +1806,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long2) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); Pointer testTask( new TimerTestTask(&this->timerCounter, &this->gsync)); @@ -1816,14 +1816,14 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long2) { t->scheduleAtFixedRate(testTask, 100, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; } ASSERT_TRUE(exception) << ("scheduleAtFixedRate after Timer.cancel() " "should throw exception"); - // Ensure a Timer throws an IllegalArgumentException if delay is negative + // Ensure a Timer throws an std::invalid_argument if delay is negative t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); exception = false; @@ -1831,7 +1831,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long2) { t->scheduleAtFixedRate(testTask, -100, 100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; } @@ -1839,7 +1839,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long2) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if period is negative + // Ensure a Timer throws an std::invalid_argument if period is negative t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); exception = false; @@ -1847,7 +1847,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long2) { t->scheduleAtFixedRate(testTask, 100, -100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; } @@ -1864,7 +1864,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long2) { Thread::sleep(400); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(report.wasRun.get() >= 2) @@ -1884,7 +1884,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Long_Long2) { Thread::sleep(1000); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } long long lastDelta = report.lastDelta; @@ -1900,7 +1900,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); TimerTestTask* testTask = new TimerTestTask(&this->timerCounter, &this->gsync); @@ -1911,7 +1911,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long) { t->scheduleAtFixedRate(testTask, d, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; // unscheduled tasks must be deleted @@ -1920,7 +1920,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long) ASSERT_TRUE(exception) << ("scheduleAtFixedRate after Timer.cancel() " "should throw exception"); - // Ensure a Timer throws an IllegalArgumentException if delay is negative + // Ensure a Timer throws an std::invalid_argument if delay is negative t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); exception = false; @@ -1929,7 +1929,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long) { t->scheduleAtFixedRate(testTask, d, 100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; // unscheduled tasks must be deleted @@ -1939,7 +1939,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if period is negative + // Ensure a Timer throws an std::invalid_argument if period is negative t.reset(new Timer()); testTask = new TimerTestTask(&this->timerCounter, &this->gsync); exception = false; @@ -1947,7 +1947,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long) { t->scheduleAtFixedRate(testTask, d, -100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; // unscheduled tasks must be deleted @@ -1965,12 +1965,12 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long) { t->scheduleAtFixedRate(NULL, d, 10); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task with negative date " "should throw IllegalArgumentException first"); @@ -1983,12 +1983,12 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long) { t->scheduleAtFixedRate(NULL, d, -10); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task & negative period " "should throw IllegalArgumentException first"); @@ -2003,7 +2003,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long) { Thread::sleep(400); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(report.wasRun.get() >= 2) @@ -2024,7 +2024,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long) { Thread::sleep(1000); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } long long lastDelta = report.lastDelta; @@ -2040,7 +2040,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long2) std::unique_ptr t; TimerTaskReport report; - // Ensure a Timer throws an IllegalStateException after cancelled + // Ensure a Timer throws std::logic_error after cancelled t.reset(new Timer()); Pointer testTask( new TimerTestTask(&this->timerCounter, &this->gsync)); @@ -2051,14 +2051,14 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long2) { t->scheduleAtFixedRate(testTask, d, 100); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { exception = true; } ASSERT_TRUE(exception) << ("scheduleAtFixedRate after Timer.cancel() " "should throw exception"); - // Ensure a Timer throws an IllegalArgumentException if delay is negative + // Ensure a Timer throws an std::invalid_argument if delay is negative t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); exception = false; @@ -2067,7 +2067,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long2) { t->scheduleAtFixedRate(testTask, d, 100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; } @@ -2075,7 +2075,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long2) "throw IllegalArgumentException"); t->cancel(); - // Ensure a Timer throws an IllegalArgumentException if period is negative + // Ensure a Timer throws an std::invalid_argument if period is negative t.reset(new Timer()); testTask.reset(new TimerTestTask(&this->timerCounter, &this->gsync)); exception = false; @@ -2083,7 +2083,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long2) { t->scheduleAtFixedRate(testTask, d, -100); } - catch (IllegalArgumentException& e) + catch (std::invalid_argument& e) { exception = true; } @@ -2099,12 +2099,12 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long2) { t->scheduleAtFixedRate(NULL, d, 10); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task with negative date " "should throw IllegalArgumentException first"); @@ -2117,12 +2117,12 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long2) { t->scheduleAtFixedRate(NULL, d, -10); } - catch (NullPointerException& e) + catch (std::invalid_argument& e) { + exception = true; } - catch (IllegalArgumentException& e) + catch (std::logic_error& e) { - exception = true; } ASSERT_TRUE(exception) << ("Scheduling a null task & negative period " "should throw IllegalArgumentException first"); @@ -2138,7 +2138,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long2) { Thread::sleep(400); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } ASSERT_TRUE(report.wasRun.get() >= 2) @@ -2159,7 +2159,7 @@ TEST_F(TimerTest, testScheduleAtFixedRate_TimerTask_Date_Long2) { Thread::sleep(1000); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } long long lastDelta = report.lastDelta; diff --git a/activemq-cpp/src/test/decaf/util/UUIDTest.cpp b/activemq-cpp/src/test/decaf/util/UUIDTest.cpp index d822dc6cd..e027602ec 100644 --- a/activemq-cpp/src/test/decaf/util/UUIDTest.cpp +++ b/activemq-cpp/src/test/decaf/util/UUIDTest.cpp @@ -18,16 +18,13 @@ #include #include -#include -#include -#include -#include #include +#include + using namespace decaf; using namespace decaf::util; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class UUIDTest : public ::testing::Test { @@ -133,11 +130,11 @@ TEST_F(UUIDTest, testTimestamp) ASSERT_EQ(0x333555577777777LL, uuid.timestamp()); uuid = UUID(0x0000000000000000LL, 0x8000000000000000LL); - ASSERT_THROW(uuid.timestamp(), UnsupportedOperationException) + ASSERT_THROW(uuid.timestamp(), std::logic_error) << ("Should throw an UnsupportedOperationException exception"); uuid = UUID(0x0000000000002000LL, 0x8000000000000000LL); - ASSERT_THROW(uuid.timestamp(), UnsupportedOperationException) + ASSERT_THROW(uuid.timestamp(), std::logic_error) << ("Should throw an UnsupportedOperationException exception"); } @@ -154,11 +151,11 @@ TEST_F(UUIDTest, testClockSequence) ASSERT_EQ(0x3FFF, uuid.clockSequence()); uuid = UUID(0x0000000000000000LL, 0x8000000000000000LL); - ASSERT_THROW(uuid.clockSequence(), UnsupportedOperationException) + ASSERT_THROW(uuid.clockSequence(), std::logic_error) << ("Should throw an UnsupportedOperationException exception"); uuid = UUID(0x0000000000002000LL, 0x8000000000000000LL); - ASSERT_THROW(uuid.clockSequence(), UnsupportedOperationException) + ASSERT_THROW(uuid.clockSequence(), std::logic_error) << ("Should throw an UnsupportedOperationException exception"); } @@ -172,11 +169,11 @@ TEST_F(UUIDTest, testNode) ASSERT_EQ(0xFFFFFFFFFFFFLL, uuid.node()); uuid = UUID(0x0000000000000000LL, 0x8000000000000000LL); - ASSERT_THROW(uuid.node(), UnsupportedOperationException) + ASSERT_THROW(uuid.node(), std::logic_error) << ("Should throw an UnsupportedOperationException exception"); uuid = UUID(0x0000000000002000LL, 0x8000000000000000LL); - ASSERT_THROW(uuid.node(), UnsupportedOperationException) + ASSERT_THROW(uuid.node(), std::logic_error) << ("Should throw an UnsupportedOperationException exception"); } @@ -282,8 +279,8 @@ TEST_F(UUIDTest, testNameUUIDFromBytes) ASSERT_EQ(0xd41d8cd98f003204ULL, (unsigned long long)uuid.getMostSignificantBits()); - ASSERT_THROW(UUID::nameUUIDFromBytes(NULL, 1), NullPointerException) - << ("Should throw an NullPointerException exception"); + ASSERT_THROW(UUID::nameUUIDFromBytes(NULL, 1), std::logic_error) + << ("Should throw std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -309,23 +306,23 @@ TEST_F(UUIDTest, testFromString) ASSERT_EQ(0, actual.clockSequence()); ASSERT_EQ(0LL, actual.node()); - ASSERT_THROW(UUID::fromString(""), IllegalArgumentException) + ASSERT_THROW(UUID::fromString(""), std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); ASSERT_THROW(UUID::fromString("f81d4fae_7dec-11d0-a765-00a0c91e6bf6"), - IllegalArgumentException) + std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); ASSERT_THROW(UUID::fromString("f81d4fae-7dec_11d0-a765-00a0c91e6bf6"), - IllegalArgumentException) + std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); ASSERT_THROW(UUID::fromString("f81d4fae-7dec-11d0_a765-00a0c91e6bf6"), - IllegalArgumentException) + std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); ASSERT_THROW(UUID::fromString("f81d4fae-7dec-11d0-a765_00a0c91e6bf6"), - IllegalArgumentException) + std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); } @@ -334,31 +331,31 @@ TEST_F(UUIDTest, testFromStringStringException) { UUID uuid = UUID::fromString("0-0-0-0-0"); - ASSERT_THROW(UUID::fromString("0-0-0-0-"), IllegalArgumentException) + ASSERT_THROW(UUID::fromString("0-0-0-0-"), std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); - ASSERT_THROW(UUID::fromString("00000"), IllegalArgumentException) + ASSERT_THROW(UUID::fromString("00000"), std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); - ASSERT_THROW(UUID::fromString("----"), IllegalArgumentException) + ASSERT_THROW(UUID::fromString("----"), std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); - ASSERT_THROW(UUID::fromString("-0-0-0-0-0"), IllegalArgumentException) + ASSERT_THROW(UUID::fromString("-0-0-0-0-0"), std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); - ASSERT_THROW(UUID::fromString("-0-0-0-0"), IllegalArgumentException) + ASSERT_THROW(UUID::fromString("-0-0-0-0"), std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); - ASSERT_THROW(UUID::fromString("-0-0-0-"), IllegalArgumentException) + ASSERT_THROW(UUID::fromString("-0-0-0-"), std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); - ASSERT_THROW(UUID::fromString("0--0-0-0"), IllegalArgumentException) + ASSERT_THROW(UUID::fromString("0--0-0-0"), std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); - ASSERT_THROW(UUID::fromString("0-0-0-0-"), IllegalArgumentException) + ASSERT_THROW(UUID::fromString("0-0-0-0-"), std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); - ASSERT_THROW(UUID::fromString("-1-0-0-0-0"), IllegalArgumentException) + ASSERT_THROW(UUID::fromString("-1-0-0-0-0"), std::invalid_argument) << ("Should throw an IllegalArgumentException exception"); uuid = UUID::fromString("123456789-0-0-0-0"); @@ -375,8 +372,8 @@ TEST_F(UUIDTest, testFromStringStringException) ASSERT_EQ(0x0LL, uuid.getLeastSignificantBits()); ASSERT_THROW(UUID::fromString("8000000000000000-0-0-0-0"), - NumberFormatException) - << ("Should throw an IllegalArgumentException exception"); + std::invalid_argument) + << ("Should throw std::invalid_argument"); uuid = UUID::fromString( "7fffffffffffffff-7fffffffffffffff-7fffffffffffffff-0-0"); @@ -390,10 +387,10 @@ TEST_F(UUIDTest, testFromStringStringException) (unsigned long long)uuid.getLeastSignificantBits()); ASSERT_THROW(UUID::fromString("0-0-0-8000000000000000-0"), - NumberFormatException) - << ("Should throw an IllegalArgumentException exception"); + std::invalid_argument) + << ("Should throw std::invalid_argument"); ASSERT_THROW(UUID::fromString("0-0-0-0-8000000000000000"), - NumberFormatException) - << ("Should throw an IllegalArgumentException exception"); + std::invalid_argument) + << ("Should throw std::invalid_argument"); } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/AbstractExecutorServiceTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/AbstractExecutorServiceTest.cpp index 84927dc76..12dd83a3b 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/AbstractExecutorServiceTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/AbstractExecutorServiceTest.cpp @@ -19,9 +19,9 @@ #include +#include #include #include -#include #include #include #include @@ -29,11 +29,11 @@ #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -77,7 +77,10 @@ class DirectExecutorService : public AbstractExecutorService { if (r == NULL) { - throw NullPointerException(__FILE__, __LINE__, "Runnable was NULL"); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Runnable was NULL"); } try @@ -158,7 +161,7 @@ TEST_F(AbstractExecutorServiceTest, testExecuteRunnable) { unexpectedException(); } - catch (InterruptedException& ex) + catch (std::runtime_error& ex) { unexpectedException(); } @@ -179,7 +182,7 @@ TEST_F(AbstractExecutorServiceTest, testSubmitCallable) { unexpectedException(); } - catch (InterruptedException& ex) + catch (std::runtime_error& ex) { unexpectedException(); } @@ -200,7 +203,7 @@ TEST_F(AbstractExecutorServiceTest, testSubmitRunnable) { unexpectedException(); } - catch (InterruptedException& ex) + catch (std::runtime_error& ex) { unexpectedException(); } @@ -221,7 +224,7 @@ TEST_F(AbstractExecutorServiceTest, testSubmitRunnable2) { unexpectedException(); } - catch (InterruptedException& ex) + catch (std::runtime_error& ex) { unexpectedException(); } @@ -237,7 +240,7 @@ TEST_F(AbstractExecutorServiceTest, testExecuteNullRunnable) e.submit(task); shouldThrow(); } - catch (NullPointerException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -256,7 +259,7 @@ TEST_F(AbstractExecutorServiceTest, testSubmitNullCallable) e.submit(t); shouldThrow(); } - catch (NullPointerException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -348,7 +351,7 @@ class TestInterruptedSubmitCallable : public Callable Thread::sleep(AbstractExecutorServiceTest::LONG_DELAY_MS); parent->threadShouldThrow(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { } @@ -388,7 +391,7 @@ class TestInterruptedSubmitRunnable : public Runnable new TestInterruptedSubmitCallable(parent))); future->get(); } - catch (InterruptedException& success) + catch (activemq::exceptions::InterruptedException& success) { } catch (Exception& e) @@ -494,7 +497,7 @@ class TestSubmitIECallable : public Callable ->get(); parent->threadShouldThrow(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { } catch (RejectedExecutionException& e2) @@ -530,7 +533,7 @@ TEST_F(AbstractExecutorServiceTest, testSubmitIE) t.interrupt(); t.join(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { unexpectedException(); } @@ -551,8 +554,8 @@ class testSubmitEECallable : public Callable virtual int call() { - throw NumberFormatException(__FILE__, - __LINE__, + throw std::invalid_argument(std::string(__FILE__) + ":" + + std::to_string(__LINE__) + ": " + "Throwing a common exception"); return 1; } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/ConcurrentStlMapTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/ConcurrentStlMapTest.cpp index f57d834d0..dcc0ecffb 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/ConcurrentStlMapTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/ConcurrentStlMapTest.cpp @@ -15,14 +15,14 @@ * limitations under the License. */ +#include #include -#include -#include #include #include #include #include #include +#include #include using namespace std; @@ -30,7 +30,7 @@ using namespace decaf; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; +using namespace activemq::exceptions; class ConcurrentStlMapTest : public ::testing::Test { @@ -74,8 +74,8 @@ TEST_F(ConcurrentStlMapTest, testConstructor) ASSERT_TRUE(map1.isEmpty()); ASSERT_TRUE(map1.size() == 0); - ASSERT_THROW(map1.get("TEST"), decaf::util::NoSuchElementException) - << ("Should Throw a NoSuchElementException"); + ASSERT_THROW(map1.get("TEST"), NoSuchElementException) + << ("Should Throw NoSuchElementException"); HashMap srcMap; srcMap.put("A", 1); @@ -239,7 +239,7 @@ TEST_F(ConcurrentStlMapTest, testGet) boolMap.get("mike"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } } @@ -302,7 +302,7 @@ TEST_F(ConcurrentStlMapTest, testValue) boolMap.get("mike"); ASSERT_TRUE(false); } - catch (decaf::util::NoSuchElementException& e) + catch (NoSuchElementException&) { } } @@ -473,8 +473,8 @@ TEST_F(ConcurrentStlMapTest, testEntrySetIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.entrySet().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -486,8 +486,8 @@ TEST_F(ConcurrentStlMapTest, testEntrySetIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -509,8 +509,8 @@ TEST_F(ConcurrentStlMapTest, testKeySetIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.keySet().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -522,8 +522,8 @@ TEST_F(ConcurrentStlMapTest, testKeySetIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -545,8 +545,8 @@ TEST_F(ConcurrentStlMapTest, testValuesIterator) << ("Iterator didn't cover the expected range"); iterator.reset(map.values().iterator()); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); count = 0; while (iterator->hasNext()) @@ -558,6 +558,6 @@ TEST_F(ConcurrentStlMapTest, testValuesIterator) ASSERT_TRUE(count++ == MAP_SIZE) << ("Iterator didn't remove the expected range"); - ASSERT_THROW(iterator->remove(), IllegalStateException) - << ("Should throw an IllegalStateException"); + ASSERT_THROW(iterator->remove(), std::logic_error) + << ("Should throw an std::logic_error"); } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/CopyOnWriteArrayListTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/CopyOnWriteArrayListTest.cpp index 8d83f31cc..d3f7cf212 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/CopyOnWriteArrayListTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/CopyOnWriteArrayListTest.cpp @@ -23,12 +23,12 @@ #include #include #include +#include using namespace decaf; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class CopyOnWriteArrayListTest : public ::testing::Test { @@ -204,8 +204,8 @@ TEST_F(CopyOnWriteArrayListTest, testAddAll2) { StlList emptyCollection; ASSERT_THROW(CopyOnWriteArrayList().addAll(-1, emptyCollection), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw an std::out_of_range"); { std::string data[] = {"1", "2", "3", "4", "5", "6", "7", "8"}; @@ -278,11 +278,11 @@ TEST_F(CopyOnWriteArrayListTest, testAddAll3) list.addAll(0, list); list.addAll(list.size(), list); - ASSERT_THROW(list.addAll(-1, list), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.addAll(-1, list), std::out_of_range) + << ("Should throw an std::out_of_range"); - ASSERT_THROW(list.addAll(list.size() + 1, list), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.addAll(list.size() + 1, list), std::out_of_range) + << ("Should throw an std::out_of_range"); } //////////////////////////////////////////////////////////////////////////////// @@ -695,7 +695,7 @@ TEST_F(CopyOnWriteArrayListTest, testIteratorRemove) it->next(); - ASSERT_THROW(it->remove(), UnsupportedOperationException) + ASSERT_THROW(it->remove(), std::logic_error) << ("Should throw an UnsupportedOperationException"); } @@ -758,8 +758,8 @@ TEST_F(CopyOnWriteArrayListTest, testAddAll1IndexOutOfBoundsException) CopyOnWriteArrayList list; StlList collection; - ASSERT_THROW(list.addAll(-1, collection), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.addAll(-1, collection), std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -771,8 +771,8 @@ TEST_F(CopyOnWriteArrayListTest, testAddAll2IndexOutOfBoundsException) StlList collection; - ASSERT_THROW(list.addAll(100, collection), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.addAll(100, collection), std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -781,8 +781,8 @@ TEST_F(CopyOnWriteArrayListTest, testListIterator1IndexOutOfBoundsException) CopyOnWriteArrayList list; ASSERT_THROW(std::unique_ptr> it(list.listIterator(-1)), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -793,8 +793,8 @@ TEST_F(CopyOnWriteArrayListTest, testListIterator2IndexOutOfBoundsException) list.add(2); ASSERT_THROW(std::unique_ptr> it(list.listIterator(100)), - IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -802,8 +802,8 @@ TEST_F(CopyOnWriteArrayListTest, testAdd1IndexOutOfBoundsException) { CopyOnWriteArrayList list; - ASSERT_THROW(list.add(-1, 42), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.add(-1, 42), std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -813,8 +813,8 @@ TEST_F(CopyOnWriteArrayListTest, testAdd2IndexOutOfBoundsException) list.add(1); list.add(2); - ASSERT_THROW(list.add(100, 42), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.add(100, 42), std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -822,8 +822,8 @@ TEST_F(CopyOnWriteArrayListTest, testRemoveAt1IndexOutOfBounds) { CopyOnWriteArrayList list; - ASSERT_THROW(list.removeAt(-1), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.removeAt(-1), std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -833,8 +833,8 @@ TEST_F(CopyOnWriteArrayListTest, testRemoveAt2IndexOutOfBounds) list.add(1); list.add(2); - ASSERT_THROW(list.removeAt(100), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.removeAt(100), std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -842,8 +842,8 @@ TEST_F(CopyOnWriteArrayListTest, testGet1IndexOutOfBoundsException) { CopyOnWriteArrayList list; - ASSERT_THROW(list.get(-1), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.get(-1), std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -853,8 +853,8 @@ TEST_F(CopyOnWriteArrayListTest, testGet2IndexOutOfBoundsException) list.add(1); list.add(2); - ASSERT_THROW(list.get(100), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.get(100), std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -862,8 +862,8 @@ TEST_F(CopyOnWriteArrayListTest, testSet1IndexOutOfBoundsException) { CopyOnWriteArrayList list; - ASSERT_THROW(list.set(-1, 42), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.set(-1, 42), std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// @@ -873,8 +873,8 @@ TEST_F(CopyOnWriteArrayListTest, testSet2IndexOutOfBoundsException) list.add(1); list.add(2); - ASSERT_THROW(list.set(100, 42), IndexOutOfBoundsException) - << ("Should throw an IndexOutOfBoundsException"); + ASSERT_THROW(list.set(100, 42), std::out_of_range) + << ("Should throw an std::out_of_range"); } ////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/decaf/util/concurrent/CopyOnWriteArraySetTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/CopyOnWriteArraySetTest.cpp index 8cbaced8a..693c6bd02 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/CopyOnWriteArraySetTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/CopyOnWriteArraySetTest.cpp @@ -19,12 +19,12 @@ #include #include +#include using namespace decaf; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::lang; -using namespace decaf::lang::exceptions; class CopyOnWriteArraySetTest : public ::testing::Test { @@ -262,7 +262,7 @@ TEST_F(CopyOnWriteArraySetTest, testIteratorRemove) std::unique_ptr> iter(full.iterator()); iter->next(); - ASSERT_THROW(iter->remove(), UnsupportedOperationException) + ASSERT_THROW(iter->remove(), std::logic_error) << ("Should throw a UnsupportedOperationException"); } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/CountDownLatchTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/CountDownLatchTest.cpp index 49313d7c1..c88188ee0 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/CountDownLatchTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/CountDownLatchTest.cpp @@ -19,10 +19,10 @@ #include #include #include +#include using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -110,7 +110,7 @@ TEST_F(CountDownLatchTest, testConstructor) CountDownLatch l(-1); shouldThrow(); } - catch (IllegalArgumentException& success) + catch (std::invalid_argument& success) { } } @@ -169,7 +169,7 @@ class TestAwaitRunnable : public Runnable latch->await(); parent->threadAssertTrue(latch->getCount() == 0); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { parent->threadUnexpectedException(); } @@ -195,7 +195,7 @@ TEST_F(CountDownLatchTest, testAwait) ASSERT_EQ(l.getCount(), 0); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -236,7 +236,7 @@ class TestTimedAwaitRunnable : public Runnable latch->await(CountDownLatchTest::SMALL_DELAY_MS, TimeUnit::MILLISECONDS)); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { parent->threadUnexpectedException(); } @@ -262,7 +262,7 @@ TEST_F(CountDownLatchTest, testTimedAwait) ASSERT_EQ(l.getCount(), 0); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -272,28 +272,27 @@ TEST_F(CountDownLatchTest, testTimedAwait) namespace { -class TestAwaitInterruptedExceptionRunnable : public Runnable +class TestAwaitRuntimeErrorRunnable : public Runnable { private: CountDownLatch* latch; CountDownLatchTest* parent; private: - TestAwaitInterruptedExceptionRunnable( - const TestAwaitInterruptedExceptionRunnable&); - TestAwaitInterruptedExceptionRunnable operator=( - const TestAwaitInterruptedExceptionRunnable&); + TestAwaitRuntimeErrorRunnable(const TestAwaitRuntimeErrorRunnable&); + TestAwaitRuntimeErrorRunnable operator=( + const TestAwaitRuntimeErrorRunnable&); public: - TestAwaitInterruptedExceptionRunnable(CountDownLatch* latch, - CountDownLatchTest* parent) + TestAwaitRuntimeErrorRunnable(CountDownLatch* latch, + CountDownLatchTest* parent) : Runnable(), latch(latch), parent(parent) { } - virtual ~TestAwaitInterruptedExceptionRunnable() + virtual ~TestAwaitRuntimeErrorRunnable() { } @@ -305,7 +304,7 @@ class TestAwaitInterruptedExceptionRunnable : public Runnable latch->await(); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -313,11 +312,11 @@ class TestAwaitInterruptedExceptionRunnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(CountDownLatchTest, testAwaitInterruptedException) +TEST_F(CountDownLatchTest, testAwaitRuntimeError) { - CountDownLatch l(1); - TestAwaitInterruptedExceptionRunnable runnable(&l, this); - Thread t(&runnable); + CountDownLatch l(1); + TestAwaitRuntimeErrorRunnable runnable(&l, this); + Thread t(&runnable); t.start(); try @@ -326,7 +325,7 @@ TEST_F(CountDownLatchTest, testAwaitInterruptedException) t.interrupt(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -336,28 +335,28 @@ TEST_F(CountDownLatchTest, testAwaitInterruptedException) namespace { -class TestTimedAwaitInterruptedExceptionRunnable : public Runnable +class TestTimedAwaitRuntimeErrorRunnable : public Runnable { private: CountDownLatch* latch; CountDownLatchTest* parent; private: - TestTimedAwaitInterruptedExceptionRunnable( - const TestTimedAwaitInterruptedExceptionRunnable&); - TestTimedAwaitInterruptedExceptionRunnable operator=( - const TestTimedAwaitInterruptedExceptionRunnable&); + TestTimedAwaitRuntimeErrorRunnable( + const TestTimedAwaitRuntimeErrorRunnable&); + TestTimedAwaitRuntimeErrorRunnable operator=( + const TestTimedAwaitRuntimeErrorRunnable&); public: - TestTimedAwaitInterruptedExceptionRunnable(CountDownLatch* latch, - CountDownLatchTest* parent) + TestTimedAwaitRuntimeErrorRunnable(CountDownLatch* latch, + CountDownLatchTest* parent) : Runnable(), latch(latch), parent(parent) { } - virtual ~TestTimedAwaitInterruptedExceptionRunnable() + virtual ~TestTimedAwaitRuntimeErrorRunnable() { } @@ -370,7 +369,7 @@ class TestTimedAwaitInterruptedExceptionRunnable : public Runnable TimeUnit::MILLISECONDS); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -378,11 +377,11 @@ class TestTimedAwaitInterruptedExceptionRunnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(CountDownLatchTest, testTimedAwaitInterruptedException) +TEST_F(CountDownLatchTest, testTimedAwaitRuntimeError) { - CountDownLatch l(1); - TestTimedAwaitInterruptedExceptionRunnable runnable(&l, this); - Thread t(&runnable); + CountDownLatch l(1); + TestTimedAwaitRuntimeErrorRunnable runnable(&l, this); + Thread t(&runnable); t.start(); try @@ -392,7 +391,7 @@ TEST_F(CountDownLatchTest, testTimedAwaitInterruptedException) t.interrupt(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -434,7 +433,7 @@ class TestAwaitTimeoutRunnable : public Runnable TimeUnit::MILLISECONDS)); parent->threadAssertTrue(latch->getCount() > 0); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { parent->threadUnexpectedException(); } @@ -455,7 +454,7 @@ TEST_F(CountDownLatchTest, testAwaitTimeout) ASSERT_EQ(l.getCount(), 1); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.cpp index 1a5aa1660..aea6f98de 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.cpp @@ -17,6 +17,9 @@ #include +#include +#include + #include #include #include @@ -26,7 +29,6 @@ using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -112,8 +114,8 @@ TEST_F(ExecutorsTest, testNewSingleThreadExecutor2) //////////////////////////////////////////////////////////////////////////////// TEST_F(ExecutorsTest, testNewSingleThreadExecutor3) { - ASSERT_THROW(Executors::newSingleThreadExecutor(NULL), NullPointerException) - << ("Should throw a NullPointerException"); + ASSERT_THROW(Executors::newSingleThreadExecutor(NULL), std::logic_error) + << ("Should throw std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -121,8 +123,8 @@ TEST_F(ExecutorsTest, testCastNewSingleThreadExecutor) { Pointer e(Executors::newSingleThreadExecutor()); - ASSERT_THROW(e.dynamicCast(), ClassCastException) - << ("Should throw a ClassCastException"); + ASSERT_THROW(e.dynamicCast(), std::bad_cast) + << ("Should throw std::bad_cast"); joinPool(e.get()); } @@ -180,14 +182,14 @@ TEST_F(ExecutorsTest, testNewFixedThreadPool2) //////////////////////////////////////////////////////////////////////////////// TEST_F(ExecutorsTest, testNewFixedThreadPool3) { - ASSERT_THROW(Executors::newFixedThreadPool(2, NULL), NullPointerException) - << ("Should throw a NullPointerException"); + ASSERT_THROW(Executors::newFixedThreadPool(2, NULL), std::logic_error) + << ("Should throw std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// TEST_F(ExecutorsTest, testNewFixedThreadPool4) { - ASSERT_THROW(Executors::newFixedThreadPool(0), IllegalArgumentException) + ASSERT_THROW(Executors::newFixedThreadPool(0), std::invalid_argument) << ("Should throw a IllegalArgumentException"); } @@ -208,8 +210,8 @@ TEST_F(ExecutorsTest, testUnconfigurableExecutorService) TEST_F(ExecutorsTest, testUnconfigurableExecutorServiceNPE) { ASSERT_THROW(Executors::unconfigurableExecutorService(NULL), - NullPointerException) - << ("Should throw a NullPointerException"); + std::logic_error) + << ("Should throw std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -229,13 +231,13 @@ TEST_F(ExecutorsTest, testCallable2) //////////////////////////////////////////////////////////////////////////////// TEST_F(ExecutorsTest, testCallableNPE1) { - ASSERT_THROW(Executors::callable(NULL), NullPointerException) - << ("Should throw a NullPointerException"); + ASSERT_THROW(Executors::callable(NULL), std::logic_error) + << ("Should throw std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// TEST_F(ExecutorsTest, testCallableNPE2) { - ASSERT_THROW(Executors::callable(NULL, 42), NullPointerException) - << ("Should throw a NullPointerException"); + ASSERT_THROW(Executors::callable(NULL, 42), std::logic_error) + << ("Should throw std::logic_error"); } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.cpp b/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.cpp index a074716bc..ab2066587 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.cpp @@ -20,7 +20,6 @@ using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -62,7 +61,7 @@ void ExecutorsTestSupport::unexpectedException() } /////////////////////////////////////////////////////////////////////////////// -void ExecutorsTestSupport::unexpectedException(Throwable& ex) +void ExecutorsTestSupport::unexpectedException(Exception& ex) { FAIL() << (std::string("Unexpected exception: ") + ex.getMessage()); } @@ -89,7 +88,7 @@ void ExecutorsTestSupport::threadUnexpectedException() } /////////////////////////////////////////////////////////////////////////////// -void ExecutorsTestSupport::threadUnexpectedException(Throwable& ex) +void ExecutorsTestSupport::threadUnexpectedException(Exception& ex) { threadFailed = true; FAIL() << (std::string("Unexpected exception: ") + ex.getMessage()); @@ -140,7 +139,7 @@ void ExecutorsTestSupport::joinPool(ExecutorService& exec) ASSERT_TRUE( exec.awaitTermination(LONG_DELAY_MS * 2, TimeUnit::MILLISECONDS)); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { FAIL() << ("Unexpected exception"); } @@ -153,9 +152,9 @@ void ExecutorsTestSupport::joinPool(ExecutorService* exec) { exec->shutdown(); ASSERT_TRUE( - exec->awaitTermination(LONG_DELAY_MS, TimeUnit::MILLISECONDS)); + exec->awaitTermination(LONG_DELAY_MS * 2, TimeUnit::MILLISECONDS)); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { FAIL() << ("Unexpected exception"); } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h b/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h index 9aa861f04..b5070d68e 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h +++ b/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -63,13 +63,13 @@ namespace util void threadFail(const std::string& reason); void threadShouldThrow(); void threadUnexpectedException(); - void threadUnexpectedException(decaf::lang::Throwable& ex); + void threadUnexpectedException(decaf::lang::Exception& ex); void threadAssertFalse(bool value); void threadAssertTrue(bool value); void threadAssertEquals(long long x, long long y); void unexpectedException(); - void unexpectedException(decaf::lang::Throwable& ex); + void unexpectedException(decaf::lang::Exception& ex); void shouldThrow(); void joinPool(ExecutorService* exec); @@ -279,7 +279,7 @@ namespace util { Thread::sleep(SMALL_DELAY_MS); } - catch (decaf::lang::exceptions::InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -381,7 +381,7 @@ namespace util { Thread::sleep(MEDIUM_DELAY_MS); } - catch (decaf::lang::exceptions::InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -482,7 +482,7 @@ namespace util { Thread::sleep(LONG_DELAY_MS); } - catch (decaf::lang::exceptions::InterruptedException& e) + catch (std::runtime_error& e) { } } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/FutureTaskTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/FutureTaskTest.cpp index 910835909..124fcbb3b 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/FutureTaskTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/FutureTaskTest.cpp @@ -17,9 +17,10 @@ #include +#include + #include #include -#include #include #include #include @@ -30,7 +31,6 @@ using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -135,7 +135,7 @@ class MediumSleepCallable : public Callable Thread::sleep(FutureTaskTest::MEDIUM_DELAY_MS); this->parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } @@ -157,16 +157,16 @@ FutureTaskTest::~FutureTaskTest() //////////////////////////////////////////////////////////////////////////////// TEST_F(FutureTaskTest, testConstructor1) { - ASSERT_THROW(new FutureTask(NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(new FutureTask(NULL), std::logic_error) + << ("Should have thrown std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// TEST_F(FutureTaskTest, testConstructor2) { ASSERT_THROW(new FutureTask(NULL, std::string("Test")), - NullPointerException) - << ("Should have thrown a NullPointerException"); + std::logic_error) + << ("Should have thrown std::logic_error"); } //////////////////////////////////////////////////////////////////////////////// @@ -240,8 +240,8 @@ TEST_F(FutureTaskTest, testSet) //////////////////////////////////////////////////////////////////////////////// TEST_F(FutureTaskTest, testSetException) { - NoSuchElementException nse; - PublicFutureTask task(new NoOpCallable()); + Exception nse(__FILE__, __LINE__, "planned exception"); + PublicFutureTask task(new NoOpCallable()); task.setException(nse); try { @@ -250,8 +250,7 @@ TEST_F(FutureTaskTest, testSetException) } catch (ExecutionException& ee) { - const NoSuchElementException* cause = - dynamic_cast(ee.getCause()); + const Exception* cause = dynamic_cast(ee.getCause()); ASSERT_TRUE(cause != NULL); } catch (Exception& e) @@ -305,7 +304,7 @@ TEST_F(FutureTaskTest, testCancelInterrupt) ASSERT_TRUE(task.isDone()); ASSERT_TRUE(task.isCancelled()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -343,7 +342,7 @@ class MediumNoInterruptsSleepCallable : public Callable { Thread::sleep(FutureTaskTest::MEDIUM_DELAY_MS); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { this->parent->threadFail("Should not interrupt"); } @@ -369,7 +368,7 @@ TEST_F(FutureTaskTest, testCancelNoInterrupt) ASSERT_TRUE(task.isDone()); ASSERT_TRUE(task.isCancelled()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -436,7 +435,7 @@ TEST_F(FutureTaskTest, testGet1) ASSERT_TRUE(ft.isDone()); ASSERT_TRUE(!ft.isCancelled()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -504,7 +503,7 @@ TEST_F(FutureTaskTest, testTimedGet1) ASSERT_TRUE(ft.isDone()); ASSERT_TRUE(!ft.isCancelled()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -542,7 +541,7 @@ class ShortSleepCallable : public Callable Thread::sleep(FutureTaskTest::MEDIUM_DELAY_MS); this->parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } @@ -610,7 +609,7 @@ TEST_F(FutureTaskTest, testTimedGetCancellation) t1.join(); t2.join(); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { unexpectedException(); } @@ -679,7 +678,7 @@ TEST_F(FutureTaskTest, testGetCancellation) t1.join(); t2.join(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { unexpectedException(); } @@ -797,7 +796,7 @@ class InterruptableFutureTaskGetRunnable : public Runnable task->get(); this->parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } catch (Exception& e) @@ -809,7 +808,7 @@ class InterruptableFutureTaskGetRunnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(FutureTaskTest, testGetInterruptedException) +TEST_F(FutureTaskTest, testGetRuntimeError) { FutureTask ft(new NoOpCallable()); Thread t(&ft); @@ -863,7 +862,7 @@ class InterruptableFutureTaskLongTimeoutGetRunnable : public Runnable task->get(FutureTaskTest::LONG_DELAY_MS, TimeUnit::MILLISECONDS); this->parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } catch (Exception& e) @@ -875,7 +874,7 @@ class InterruptableFutureTaskLongTimeoutGetRunnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(FutureTaskTest, testTimedGetInterruptedException2) +TEST_F(FutureTaskTest, testTimedGetRuntimeError2) { FutureTask ft(new NoOpCallable()); InterruptableFutureTaskLongTimeoutGetRunnable runner(this, &ft); diff --git a/activemq-cpp/src/test/decaf/util/concurrent/LinkedBlockingQueueTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/LinkedBlockingQueueTest.cpp index b49e8e477..0d0b9bae0 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/LinkedBlockingQueueTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/LinkedBlockingQueueTest.cpp @@ -17,18 +17,19 @@ #include +#include #include -#include #include #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; +using namespace activemq::exceptions; using namespace decaf::util::concurrent; class LinkedBlockingQueueTest : public ExecutorsTestSupport @@ -150,7 +151,7 @@ TEST_F(LinkedBlockingQueueTest, testConstructor3) /////////////////////////////////////////////////////////////////////////////// TEST_F(LinkedBlockingQueueTest, testConstructor4) { - ASSERT_THROW(LinkedBlockingQueue(-1), IllegalArgumentException) + ASSERT_THROW(LinkedBlockingQueue(-1), std::invalid_argument) << ("Should have thrown an IllegalArgumentException"); } @@ -225,8 +226,8 @@ TEST_F(LinkedBlockingQueueTest, testAdd) } ASSERT_EQ(0, q.remainingCapacity()); - ASSERT_THROW(q.add(SIZE), IllegalStateException) - << ("Should have thrown an IllegalStateException"); + ASSERT_THROW(q.add(SIZE), std::logic_error) + << ("Should have thrown an std::logic_error"); } /////////////////////////////////////////////////////////////////////////////// @@ -235,7 +236,7 @@ TEST_F(LinkedBlockingQueueTest, testAddAllSelf) LinkedBlockingQueue q(SIZE); populate(q, SIZE); - ASSERT_THROW(q.addAll(q), IllegalArgumentException) + ASSERT_THROW(q.addAll(q), std::invalid_argument) << ("Should have thrown an IllegalArgumentException"); } @@ -247,8 +248,8 @@ TEST_F(LinkedBlockingQueueTest, testAddAll1) populate(list, SIZE); - ASSERT_THROW(q.addAll(list), IllegalStateException) - << ("Should have thrown an IllegalStateException"); + ASSERT_THROW(q.addAll(list), std::logic_error) + << ("Should have thrown an std::logic_error"); } /////////////////////////////////////////////////////////////////////////////// @@ -374,7 +375,7 @@ TEST_F(LinkedBlockingQueueTest, testElement) } ASSERT_THROW(q.element(), NoSuchElementException) - << ("Should have thrown an NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); } /////////////////////////////////////////////////////////////////////////////// @@ -389,7 +390,7 @@ TEST_F(LinkedBlockingQueueTest, testRemove) } ASSERT_THROW(q.remove(), NoSuchElementException) - << ("Should have thrown an NoSuchElementException"); + << ("Should have thrown NoSuchElementException"); } /////////////////////////////////////////////////////////////////////////////// @@ -552,7 +553,7 @@ TEST_F(LinkedBlockingQueueTest, testDrainToSelf) LinkedBlockingQueue q(SIZE); populate(q, SIZE); - ASSERT_THROW(q.drainTo(q), IllegalArgumentException) + ASSERT_THROW(q.drainTo(q), std::invalid_argument) << ("Should have thrown an IllegalArgumentException"); } @@ -596,7 +597,7 @@ TEST_F(LinkedBlockingQueueTest, testDrainToSelfN) LinkedBlockingQueue q(SIZE); populate(q, SIZE); - ASSERT_THROW(q.drainTo(q, SIZE), IllegalArgumentException) + ASSERT_THROW(q.drainTo(q, SIZE), std::invalid_argument) << ("Should have thrown an IllegalArgumentException"); } @@ -654,7 +655,7 @@ class PutThread : public Thread { theQ->put(putValue); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { // TODO deal with exceptions in threads. } @@ -795,7 +796,7 @@ class PuttingThread : public Thread Thread::sleep(1); } } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { // TODO deal with exceptions in threads. } @@ -836,7 +837,7 @@ class TakingThread : public Thread Thread::sleep(1); } } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { // TODO deal with exceptions in threads. } @@ -1059,7 +1060,7 @@ class TestBlockingPutRunnable : public Runnable q.put(LinkedBlockingQueueTest::SIZE); test->threadShouldThrow(); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { test->threadAssertEquals(added, LinkedBlockingQueueTest::SIZE); } @@ -1080,7 +1081,7 @@ TEST_F(LinkedBlockingQueueTest, testBlockingPut) t.interrupt(); t.join(); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { unexpectedException(); } @@ -1128,7 +1129,7 @@ class TestTimedOfferRunnable : public Runnable TimeUnit::MILLISECONDS); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1189,7 +1190,7 @@ class TestTakeFromEmptyRunnable : public Runnable queue->take(); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1254,7 +1255,7 @@ class TestBlockingTakeRunnable : public Runnable queue.take(); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1274,9 +1275,9 @@ TEST_F(LinkedBlockingQueueTest, testBlockingTake) t.interrupt(); t.join(); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { - unexpectedException(ie); + unexpectedException(); } } @@ -1324,7 +1325,7 @@ class TestInterruptedTimedPollRunnable : public Runnable TimeUnit::MILLISECONDS)); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1344,7 +1345,7 @@ TEST_F(LinkedBlockingQueueTest, testInterruptedTimedPoll) t.interrupt(); t.join(); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { unexpectedException(); } @@ -1396,7 +1397,7 @@ class TestTimedPollWithOfferRunnable : public Runnable TimeUnit::MILLISECONDS); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1462,9 +1463,9 @@ class TestOfferInExecutor1 : public Runnable TimeUnit::MILLISECONDS)); test->threadAssertEquals(0, queue->remainingCapacity()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { - test->threadUnexpectedException(e); + test->threadUnexpectedException(); } } }; @@ -1500,9 +1501,9 @@ class TestOfferInExecutor2 : public Runnable Thread::sleep(LinkedBlockingQueueTest::SMALL_DELAY_MS); test->threadAssertEquals(1, queue->take()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { - test->threadUnexpectedException(e); + test->threadUnexpectedException(); } } }; @@ -1562,9 +1563,9 @@ class TestPollInExecutor1 : public Runnable TimeUnit::MILLISECONDS)); test->threadAssertTrue(queue->isEmpty()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { - test->threadUnexpectedException(e); + test->threadUnexpectedException(); } } }; @@ -1599,9 +1600,9 @@ class TestPollInExecutor2 : public Runnable Thread::sleep(LinkedBlockingQueueTest::SMALL_DELAY_MS); queue->put(1); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { - test->threadUnexpectedException(e); + test->threadUnexpectedException(); } } }; diff --git a/activemq-cpp/src/test/decaf/util/concurrent/MutexTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/MutexTest.cpp index 0a17c2364..d99afc7ac 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/MutexTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/MutexTest.cpp @@ -27,10 +27,11 @@ #include +#include + using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::internal::util::concurrent; @@ -233,13 +234,13 @@ TEST_F(MutexTest, testTimedWait) Mutex test; test.lock(); - ASSERT_THROW(test.wait(-1, -1), IllegalArgumentException) + ASSERT_THROW(test.wait(-1, -1), std::invalid_argument) << ("Should Throw an IllegalArgumentException"); - ASSERT_THROW(test.wait(1, 9999999), IllegalArgumentException) + ASSERT_THROW(test.wait(1, 9999999), std::invalid_argument) << ("Should Throw an IllegalArgumentException"); - ASSERT_THROW(test.wait(0, -1), IllegalArgumentException) + ASSERT_THROW(test.wait(0, -1), std::invalid_argument) << ("Should Throw an IllegalArgumentException"); } } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/SemaphoreTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/SemaphoreTest.cpp index 458b23921..18795213d 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/SemaphoreTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/SemaphoreTest.cpp @@ -30,7 +30,6 @@ using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::locks; @@ -97,7 +96,7 @@ class InterruptibleLockRunnable : public Runnable { lock->acquire(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -132,7 +131,7 @@ class InterruptedLockRunnable : public Runnable lock->acquire(); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -206,7 +205,7 @@ TEST_F(SemaphoreTest, testAcquireReleaseInSameThread) s.release(); ASSERT_EQ(1, s.availablePermits()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -253,7 +252,7 @@ TEST_F(SemaphoreTest, testTimedAcquireReleaseInSameThread) s.release(); ASSERT_EQ(1, s.availablePermits()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -297,7 +296,7 @@ class TestAcquireReleaseInDifferentThreadsRunnable : public Runnable sem->release(); sem->acquire(); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { parent->threadUnexpectedException(); } @@ -323,7 +322,7 @@ TEST_F(SemaphoreTest, testAcquireReleaseInDifferentThreads) s.release(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -389,7 +388,7 @@ TEST_F(SemaphoreTest, testUninterruptibleAcquireReleaseInDifferentThreads) s.release(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -437,7 +436,7 @@ class TestTimedAcquireReleaseInDifferentThreadsRunnable : public Runnable sem->tryAcquire(SemaphoreTest::SHORT_DELAY_MS, TimeUnit::MILLISECONDS)); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { parent->threadUnexpectedException(); } @@ -462,7 +461,7 @@ TEST_F(SemaphoreTest, testTimedAcquireReleaseInDifferentThreads) s.release(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -472,28 +471,26 @@ TEST_F(SemaphoreTest, testTimedAcquireReleaseInDifferentThreads) namespace { -class TestAcquireInterruptedExceptionRunnable : public Runnable +class TestAcquireRuntimeErrorRunnable : public Runnable { private: Semaphore* sem; SemaphoreTest* parent; private: - TestAcquireInterruptedExceptionRunnable( - const TestAcquireInterruptedExceptionRunnable&); - TestAcquireInterruptedExceptionRunnable operator=( - const TestAcquireInterruptedExceptionRunnable&); + TestAcquireRuntimeErrorRunnable(const TestAcquireRuntimeErrorRunnable&); + TestAcquireRuntimeErrorRunnable operator=( + const TestAcquireRuntimeErrorRunnable&); public: - TestAcquireInterruptedExceptionRunnable(Semaphore* sem, - SemaphoreTest* parent) + TestAcquireRuntimeErrorRunnable(Semaphore* sem, SemaphoreTest* parent) : Runnable(), sem(sem), parent(parent) { } - virtual ~TestAcquireInterruptedExceptionRunnable() + virtual ~TestAcquireRuntimeErrorRunnable() { } @@ -504,7 +501,7 @@ class TestAcquireInterruptedExceptionRunnable : public Runnable sem->acquire(); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -512,11 +509,11 @@ class TestAcquireInterruptedExceptionRunnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(SemaphoreTest, testAcquireInterruptedException) +TEST_F(SemaphoreTest, testAcquireRuntimeError) { - Semaphore s(0, false); - TestAcquireInterruptedExceptionRunnable runnable(&s, this); - Thread t(&runnable); + Semaphore s(0, false); + TestAcquireRuntimeErrorRunnable runnable(&s, this); + Thread t(&runnable); t.start(); try @@ -525,7 +522,7 @@ TEST_F(SemaphoreTest, testAcquireInterruptedException) t.interrupt(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -535,28 +532,27 @@ TEST_F(SemaphoreTest, testAcquireInterruptedException) namespace { -class TestTryAcquireInterruptedExceptionRunnable : public Runnable +class TestTryAcquireRuntimeErrorRunnable : public Runnable { private: Semaphore* sem; SemaphoreTest* parent; private: - TestTryAcquireInterruptedExceptionRunnable( - const TestTryAcquireInterruptedExceptionRunnable&); - TestTryAcquireInterruptedExceptionRunnable operator=( - const TestTryAcquireInterruptedExceptionRunnable&); + TestTryAcquireRuntimeErrorRunnable( + const TestTryAcquireRuntimeErrorRunnable&); + TestTryAcquireRuntimeErrorRunnable operator=( + const TestTryAcquireRuntimeErrorRunnable&); public: - TestTryAcquireInterruptedExceptionRunnable(Semaphore* sem, - SemaphoreTest* parent) + TestTryAcquireRuntimeErrorRunnable(Semaphore* sem, SemaphoreTest* parent) : Runnable(), sem(sem), parent(parent) { } - virtual ~TestTryAcquireInterruptedExceptionRunnable() + virtual ~TestTryAcquireRuntimeErrorRunnable() { } @@ -568,7 +564,7 @@ class TestTryAcquireInterruptedExceptionRunnable : public Runnable TimeUnit::MILLISECONDS); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -576,11 +572,11 @@ class TestTryAcquireInterruptedExceptionRunnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(SemaphoreTest, testTryAcquireInterruptedException) +TEST_F(SemaphoreTest, testTryAcquireRuntimeError) { - Semaphore s(0, false); - TestAcquireInterruptedExceptionRunnable runnable(&s, this); - Thread t(&runnable); + Semaphore s(0, false); + TestAcquireRuntimeErrorRunnable runnable(&s, this); + Thread t(&runnable); t.start(); try @@ -589,7 +585,7 @@ TEST_F(SemaphoreTest, testTryAcquireInterruptedException) t.interrupt(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -792,7 +788,7 @@ TEST_F(SemaphoreTest, testAcquireReleaseInSameThreadFair) s.release(); ASSERT_EQ(1, s.availablePermits()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -816,7 +812,7 @@ TEST_F(SemaphoreTest, testAcquireReleaseNInSameThreadFair) s.acquire(5); ASSERT_EQ(1, s.availablePermits()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -863,7 +859,7 @@ TEST_F(SemaphoreTest, testTimedAcquireReleaseNInSameThreadFair) ASSERT_TRUE(s.tryAcquire(5, SHORT_DELAY_MS, TimeUnit::MILLISECONDS)); ASSERT_EQ(1, s.availablePermits()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -887,7 +883,7 @@ TEST_F(SemaphoreTest, testTimedAcquireReleaseInSameThreadFair) s.release(); ASSERT_EQ(1, s.availablePermits()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -931,7 +927,7 @@ class TestAcquireReleaseInDifferentThreadsFairRunnable : public Runnable sem->acquire(); sem->acquire(); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { parent->threadUnexpectedException(); } @@ -959,7 +955,7 @@ TEST_F(SemaphoreTest, testAcquireReleaseInDifferentThreadsFair) t.join(); ASSERT_EQ(2, s.availablePermits()); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -1002,7 +998,7 @@ class TestAcquireReleaseNInDifferentThreadsFairRunnable : public Runnable sem->release(2); sem->acquire(); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { parent->threadUnexpectedException(); } @@ -1026,7 +1022,7 @@ TEST_F(SemaphoreTest, testAcquireReleaseNInDifferentThreadsFair) s.release(1); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -1069,7 +1065,7 @@ class TestAcquireReleaseNInDifferentThreadsFair2Runnable : public Runnable sem->acquire(2); sem->release(4); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { parent->threadUnexpectedException(); } @@ -1094,7 +1090,7 @@ TEST_F(SemaphoreTest, testAcquireReleaseNInDifferentThreadsFair2) s.release(2); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -1149,7 +1145,7 @@ class TestTimedAcquireReleaseInDifferentThreadsFairRunnable : public Runnable sem->tryAcquire(SemaphoreTest::SHORT_DELAY_MS, TimeUnit::MILLISECONDS)); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { parent->threadUnexpectedException(); } @@ -1174,7 +1170,7 @@ TEST_F(SemaphoreTest, testTimedAcquireReleaseInDifferentThreadsFair) s.release(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -1224,7 +1220,7 @@ class TestTimedAcquireReleaseNInDifferentThreadsFairRunnable : public Runnable TimeUnit::MILLISECONDS)); sem->release(2); } - catch (InterruptedException& ie) + catch (std::runtime_error& ie) { parent->threadUnexpectedException(); } @@ -1248,7 +1244,7 @@ TEST_F(SemaphoreTest, testTimedAcquireReleaseNInDifferentThreadsFair) s.release(2); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -1258,28 +1254,27 @@ TEST_F(SemaphoreTest, testTimedAcquireReleaseNInDifferentThreadsFair) namespace { -class TestAcquireInterruptedExceptionFairRunnable : public Runnable +class TestAcquireRuntimeErrorFairRunnable : public Runnable { private: Semaphore* sem; SemaphoreTest* parent; private: - TestAcquireInterruptedExceptionFairRunnable( - const TestAcquireInterruptedExceptionFairRunnable&); - TestAcquireInterruptedExceptionFairRunnable operator=( - const TestAcquireInterruptedExceptionFairRunnable&); + TestAcquireRuntimeErrorFairRunnable( + const TestAcquireRuntimeErrorFairRunnable&); + TestAcquireRuntimeErrorFairRunnable operator=( + const TestAcquireRuntimeErrorFairRunnable&); public: - TestAcquireInterruptedExceptionFairRunnable(Semaphore* sem, - SemaphoreTest* parent) + TestAcquireRuntimeErrorFairRunnable(Semaphore* sem, SemaphoreTest* parent) : Runnable(), sem(sem), parent(parent) { } - virtual ~TestAcquireInterruptedExceptionFairRunnable() + virtual ~TestAcquireRuntimeErrorFairRunnable() { } @@ -1290,7 +1285,7 @@ class TestAcquireInterruptedExceptionFairRunnable : public Runnable sem->acquire(); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1298,11 +1293,11 @@ class TestAcquireInterruptedExceptionFairRunnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(SemaphoreTest, testAcquireInterruptedExceptionFair) +TEST_F(SemaphoreTest, testAcquireRuntimeErrorFair) { - Semaphore s(0, true); - TestAcquireInterruptedExceptionFairRunnable runnable(&s, this); - Thread t(&runnable); + Semaphore s(0, true); + TestAcquireRuntimeErrorFairRunnable runnable(&s, this); + Thread t(&runnable); t.start(); try @@ -1311,7 +1306,7 @@ TEST_F(SemaphoreTest, testAcquireInterruptedExceptionFair) t.interrupt(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -1321,28 +1316,27 @@ TEST_F(SemaphoreTest, testAcquireInterruptedExceptionFair) namespace { -class TestAcquireNInterruptedExceptionFairRunnable : public Runnable +class TestAcquireNRuntimeErrorFairRunnable : public Runnable { private: Semaphore* sem; SemaphoreTest* parent; private: - TestAcquireNInterruptedExceptionFairRunnable( - const TestAcquireNInterruptedExceptionFairRunnable&); - TestAcquireNInterruptedExceptionFairRunnable operator=( - const TestAcquireNInterruptedExceptionFairRunnable&); + TestAcquireNRuntimeErrorFairRunnable( + const TestAcquireNRuntimeErrorFairRunnable&); + TestAcquireNRuntimeErrorFairRunnable operator=( + const TestAcquireNRuntimeErrorFairRunnable&); public: - TestAcquireNInterruptedExceptionFairRunnable(Semaphore* sem, - SemaphoreTest* parent) + TestAcquireNRuntimeErrorFairRunnable(Semaphore* sem, SemaphoreTest* parent) : Runnable(), sem(sem), parent(parent) { } - virtual ~TestAcquireNInterruptedExceptionFairRunnable() + virtual ~TestAcquireNRuntimeErrorFairRunnable() { } @@ -1353,7 +1347,7 @@ class TestAcquireNInterruptedExceptionFairRunnable : public Runnable sem->acquire(3); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1361,11 +1355,11 @@ class TestAcquireNInterruptedExceptionFairRunnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(SemaphoreTest, testAcquireNInterruptedExceptionFair) +TEST_F(SemaphoreTest, testAcquireNRuntimeErrorFair) { - Semaphore s(2, true); - TestAcquireNInterruptedExceptionFairRunnable runnable(&s, this); - Thread t(&runnable); + Semaphore s(2, true); + TestAcquireNRuntimeErrorFairRunnable runnable(&s, this); + Thread t(&runnable); t.start(); try @@ -1374,7 +1368,7 @@ TEST_F(SemaphoreTest, testAcquireNInterruptedExceptionFair) t.interrupt(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -1384,28 +1378,28 @@ TEST_F(SemaphoreTest, testAcquireNInterruptedExceptionFair) namespace { -class TestTryAcquireInterruptedExceptionFairRunnable : public Runnable +class TestTryAcquireRuntimeErrorFairRunnable : public Runnable { private: Semaphore* sem; SemaphoreTest* parent; private: - TestTryAcquireInterruptedExceptionFairRunnable( - const TestTryAcquireInterruptedExceptionFairRunnable&); - TestTryAcquireInterruptedExceptionFairRunnable operator=( - const TestTryAcquireInterruptedExceptionFairRunnable&); + TestTryAcquireRuntimeErrorFairRunnable( + const TestTryAcquireRuntimeErrorFairRunnable&); + TestTryAcquireRuntimeErrorFairRunnable operator=( + const TestTryAcquireRuntimeErrorFairRunnable&); public: - TestTryAcquireInterruptedExceptionFairRunnable(Semaphore* sem, - SemaphoreTest* parent) + TestTryAcquireRuntimeErrorFairRunnable(Semaphore* sem, + SemaphoreTest* parent) : Runnable(), sem(sem), parent(parent) { } - virtual ~TestTryAcquireInterruptedExceptionFairRunnable() + virtual ~TestTryAcquireRuntimeErrorFairRunnable() { } @@ -1417,7 +1411,7 @@ class TestTryAcquireInterruptedExceptionFairRunnable : public Runnable TimeUnit::MILLISECONDS); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1425,11 +1419,11 @@ class TestTryAcquireInterruptedExceptionFairRunnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(SemaphoreTest, testTryAcquireInterruptedExceptionFair) +TEST_F(SemaphoreTest, testTryAcquireRuntimeErrorFair) { - Semaphore s(0, true); - TestTryAcquireInterruptedExceptionFairRunnable runnable(&s, this); - Thread t(&runnable); + Semaphore s(0, true); + TestTryAcquireRuntimeErrorFairRunnable runnable(&s, this); + Thread t(&runnable); t.start(); try @@ -1438,7 +1432,7 @@ TEST_F(SemaphoreTest, testTryAcquireInterruptedExceptionFair) t.interrupt(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } @@ -1448,28 +1442,28 @@ TEST_F(SemaphoreTest, testTryAcquireInterruptedExceptionFair) namespace { -class TestTryAcquireNInterruptedExceptionFairRunnable : public Runnable +class TestTryAcquireNRuntimeErrorFairRunnable : public Runnable { private: Semaphore* sem; SemaphoreTest* parent; private: - TestTryAcquireNInterruptedExceptionFairRunnable( - const TestTryAcquireNInterruptedExceptionFairRunnable&); - TestTryAcquireNInterruptedExceptionFairRunnable operator=( - const TestTryAcquireNInterruptedExceptionFairRunnable&); + TestTryAcquireNRuntimeErrorFairRunnable( + const TestTryAcquireNRuntimeErrorFairRunnable&); + TestTryAcquireNRuntimeErrorFairRunnable operator=( + const TestTryAcquireNRuntimeErrorFairRunnable&); public: - TestTryAcquireNInterruptedExceptionFairRunnable(Semaphore* sem, - SemaphoreTest* parent) + TestTryAcquireNRuntimeErrorFairRunnable(Semaphore* sem, + SemaphoreTest* parent) : Runnable(), sem(sem), parent(parent) { } - virtual ~TestTryAcquireNInterruptedExceptionFairRunnable() + virtual ~TestTryAcquireNRuntimeErrorFairRunnable() { } @@ -1482,7 +1476,7 @@ class TestTryAcquireNInterruptedExceptionFairRunnable : public Runnable TimeUnit::MILLISECONDS); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1490,11 +1484,11 @@ class TestTryAcquireNInterruptedExceptionFairRunnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(SemaphoreTest, testTryAcquireNInterruptedExceptionFair) +TEST_F(SemaphoreTest, testTryAcquireNRuntimeErrorFair) { - Semaphore s(1, true); - TestTryAcquireNInterruptedExceptionFairRunnable runnable(&s, this); - Thread t(&runnable); + Semaphore s(1, true); + TestTryAcquireNRuntimeErrorFairRunnable runnable(&s, this); + Thread t(&runnable); t.start(); try @@ -1503,7 +1497,7 @@ TEST_F(SemaphoreTest, testTryAcquireNInterruptedExceptionFair) t.interrupt(); t.join(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { unexpectedException(); } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.cpp index 7d9436df7..a8221f893 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.cpp @@ -17,12 +17,14 @@ #include +#include + #include #include #include +#include #include -#include #include #include #include @@ -32,7 +34,6 @@ using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; @@ -102,7 +103,7 @@ class MyExceptionTask : public lang::Runnable virtual void run() { - throw RuntimeException(); + throw Exception(); } }; @@ -211,7 +212,7 @@ class MyThreadPoolExecutor : public ThreadPoolExecutor beforeCalled = true; } - void afterExecute(Runnable* r, Throwable* t) + void afterExecute(Runnable* r, Exception* t) { afterCalled = true; } @@ -627,8 +628,8 @@ TEST_F(ThreadPoolExecutorTest, testSetRejectedExecutionHandlerNull) TimeUnit::MILLISECONDS, new LinkedBlockingQueue()); - ASSERT_THROW(p.setRejectedExecutionHandler(NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(p.setRejectedExecutionHandler(NULL), std::logic_error) + << ("Should have thrown std::logic_error"); joinPool(p); } @@ -890,7 +891,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor1) LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -905,7 +906,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor2) LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -920,7 +921,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor3) LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -932,7 +933,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor4) ASSERT_THROW( new ThreadPoolExecutor(1, 2, -1LL, TimeUnit::MILLISECONDS, queue.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -947,7 +948,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor5) LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -964,7 +965,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor6) TimeUnit::MILLISECONDS, queue.get(), factory.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -981,7 +982,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor7) TimeUnit::MILLISECONDS, queue.get(), factory.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -998,7 +999,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor8) TimeUnit::MILLISECONDS, queue.get(), factory.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1015,7 +1016,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor9) TimeUnit::MILLISECONDS, queue.get(), factory.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1032,7 +1033,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor10) TimeUnit::MILLISECONDS, queue.get(), factory.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1049,7 +1050,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor11) TimeUnit::MILLISECONDS, queue.get(), handler.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1066,7 +1067,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor12) TimeUnit::MILLISECONDS, queue.get(), handler.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1083,7 +1084,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor13) TimeUnit::MILLISECONDS, queue.get(), handler.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1100,7 +1101,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor14) TimeUnit::MILLISECONDS, queue.get(), handler.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1117,7 +1118,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor15) TimeUnit::MILLISECONDS, queue.get(), handler.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1136,7 +1137,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor16) queue.get(), factory.get(), handler.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1155,7 +1156,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor17) queue.get(), factory.get(), handler.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1174,7 +1175,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor18) queue.get(), factory.get(), handler.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1193,7 +1194,7 @@ TEST_F(ThreadPoolExecutorTest, testConstructor19) queue.get(), factory.get(), handler.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } @@ -1212,12 +1213,12 @@ TEST_F(ThreadPoolExecutorTest, testConstructor20) queue.get(), factory.get(), handler.get()), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); } /////////////////////////////////////////////////////////////////////////////// -TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException1) +TEST_F(ThreadPoolExecutorTest, testConstructorStdLogicError1) { Pointer> queue( new LinkedBlockingQueue()); @@ -1227,12 +1228,12 @@ TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException1) LONG_DELAY_MS, TimeUnit::MILLISECONDS, NULL), - NullPointerException) - << ("Should have thrown a NullPointerException"); + std::logic_error) + << ("Should have thrown std::logic_error"); } /////////////////////////////////////////////////////////////////////////////// -TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException2) +TEST_F(ThreadPoolExecutorTest, testConstructorStdLogicError2) { Pointer> queue( new LinkedBlockingQueue()); @@ -1244,12 +1245,12 @@ TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException2) TimeUnit::MILLISECONDS, NULL, factory.get()), - NullPointerException) - << ("Should have thrown a NullPointerException"); + std::logic_error) + << ("Should have thrown std::logic_error"); } /////////////////////////////////////////////////////////////////////////////// -TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException3) +TEST_F(ThreadPoolExecutorTest, testConstructorStdLogicError3) { Pointer> queue( new LinkedBlockingQueue()); @@ -1260,12 +1261,12 @@ TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException3) TimeUnit::MILLISECONDS, queue.get(), (ThreadFactory*)NULL), - NullPointerException) - << ("Should have thrown a NullPointerException"); + std::logic_error) + << ("Should have thrown std::logic_error"); } /////////////////////////////////////////////////////////////////////////////// -TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException4) +TEST_F(ThreadPoolExecutorTest, testConstructorStdLogicError4) { Pointer handler(new NoOpREHandler()); @@ -1275,12 +1276,12 @@ TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException4) TimeUnit::MILLISECONDS, NULL, handler.get()), - NullPointerException) - << ("Should have thrown a NullPointerException"); + std::logic_error) + << ("Should have thrown std::logic_error"); } /////////////////////////////////////////////////////////////////////////////// -TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException5) +TEST_F(ThreadPoolExecutorTest, testConstructorStdLogicError5) { Pointer> queue( new LinkedBlockingQueue()); @@ -1291,12 +1292,12 @@ TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException5) TimeUnit::MILLISECONDS, queue.get(), (RejectedExecutionHandler*)NULL), - NullPointerException) - << ("Should have thrown a NullPointerException"); + std::logic_error) + << ("Should have thrown std::logic_error"); } /////////////////////////////////////////////////////////////////////////////// -TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException6) +TEST_F(ThreadPoolExecutorTest, testConstructorStdLogicError6) { Pointer factory(new SimpleThreadFactory()); Pointer handler(new NoOpREHandler()); @@ -1308,12 +1309,12 @@ TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException6) NULL, factory.get(), handler.get()), - NullPointerException) - << ("Should have thrown a NullPointerException"); + std::logic_error) + << ("Should have thrown std::logic_error"); } /////////////////////////////////////////////////////////////////////////////// -TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException7) +TEST_F(ThreadPoolExecutorTest, testConstructorStdLogicError7) { Pointer> queue( new LinkedBlockingQueue()); @@ -1326,12 +1327,12 @@ TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException7) queue.get(), factory.get(), (RejectedExecutionHandler*)NULL), - NullPointerException) - << ("Should have thrown a NullPointerException"); + std::logic_error) + << ("Should have thrown std::logic_error"); } /////////////////////////////////////////////////////////////////////////////// -TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException8) +TEST_F(ThreadPoolExecutorTest, testConstructorStdLogicError8) { Pointer> queue( new LinkedBlockingQueue()); @@ -1344,8 +1345,8 @@ TEST_F(ThreadPoolExecutorTest, testConstructorNullPointerException8) queue.get(), (ThreadFactory*)NULL, handler.get()), - NullPointerException) - << ("Should have thrown a NullPointerException"); + std::logic_error) + << ("Should have thrown std::logic_error"); } /////////////////////////////////////////////////////////////////////////////// @@ -1607,8 +1608,8 @@ TEST_F(ThreadPoolExecutorTest, testExecuteNull) TimeUnit::MILLISECONDS, new LinkedBlockingQueue()); - ASSERT_THROW(tpe.execute(NULL), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(tpe.execute(NULL), std::logic_error) + << ("Should have thrown std::logic_error"); tpe.shutdown(); @@ -1624,7 +1625,7 @@ TEST_F(ThreadPoolExecutorTest, testCorePoolSizeIllegalArgumentException) TimeUnit::MILLISECONDS, new LinkedBlockingQueue()); - ASSERT_THROW(tpe.setCorePoolSize(-1), IllegalArgumentException) + ASSERT_THROW(tpe.setCorePoolSize(-1), std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); tpe.shutdown(); @@ -1641,7 +1642,7 @@ TEST_F(ThreadPoolExecutorTest, testMaximumPoolSizeIllegalArgumentException1) TimeUnit::MILLISECONDS, new LinkedBlockingQueue()); - ASSERT_THROW(tpe.setMaximumPoolSize(1), IllegalArgumentException) + ASSERT_THROW(tpe.setMaximumPoolSize(1), std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); tpe.shutdown(); @@ -1658,7 +1659,7 @@ TEST_F(ThreadPoolExecutorTest, testMaximumPoolSizeIllegalArgumentException2) TimeUnit::MILLISECONDS, new LinkedBlockingQueue()); - ASSERT_THROW(tpe.setMaximumPoolSize(-1), IllegalArgumentException) + ASSERT_THROW(tpe.setMaximumPoolSize(-1), std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); tpe.shutdown(); @@ -1676,7 +1677,7 @@ TEST_F(ThreadPoolExecutorTest, testKeepAliveTimeIllegalArgumentException) new LinkedBlockingQueue()); ASSERT_THROW(tpe.setKeepAliveTime(-1, TimeUnit::MILLISECONDS), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); tpe.shutdown(); diff --git a/activemq-cpp/src/test/decaf/util/concurrent/TimeUnitTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/TimeUnitTest.cpp index eac817e2d..617ee2004 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/TimeUnitTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/TimeUnitTest.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include using namespace decaf; @@ -257,7 +258,6 @@ TEST_F(TimeUnitTest, testValueOf) ASSERT_TRUE(TimeUnit::DAYS == TimeUnit::valueOf("DAYS")); ASSERT_TRUE(TimeUnit::HOURS == TimeUnit::valueOf("HOURS")); - ASSERT_THROW(TimeUnit::valueOf("FOO"), - decaf::lang::exceptions::IllegalArgumentException) + ASSERT_THROW(TimeUnit::valueOf("FOO"), std::invalid_argument) << ("Should Throw an IllegalArgumentException"); } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/locks/AbstractQueuedSynchronizerTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/locks/AbstractQueuedSynchronizerTest.cpp index d28d224c7..f21b92b45 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/locks/AbstractQueuedSynchronizerTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/locks/AbstractQueuedSynchronizerTest.cpp @@ -17,6 +17,9 @@ #include +#include + +#include #include #include #include @@ -25,11 +28,11 @@ #include #include #include +#include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::locks; @@ -71,7 +74,10 @@ class TestMutex : public AbstractQueuedSynchronizer { if (getState() == 0) { - throw IllegalMonitorStateException(); + throw activemq::exceptions::IllegalStateException( + __FILE__, + __LINE__, + "Illegal monitor state"); } setState(0); return true; @@ -143,7 +149,7 @@ class InterruptibleSyncRunnable : public Runnable { mutex->acquireInterruptibly(1); } - catch (InterruptedException& success) + catch (activemq::exceptions::InterruptedException& success) { } catch (Exception& ex) @@ -187,7 +193,7 @@ class InterruptedSyncRunnable : public Runnable mutex->acquireInterruptibly(1); parent->threadFail("Should have been interrupted."); } - catch (InterruptedException& success) + catch (activemq::exceptions::InterruptedException& success) { } catch (Exception& ex) @@ -284,7 +290,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testIsQueuedNPE) mutex.isQueued(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (activemq::exceptions::NullPointerException& success) { } } @@ -573,27 +579,26 @@ TEST_F(AbstractQueuedSynchronizerTest, testGetSharedQueuedThreads) namespace { -class TestInterruptedException2Runnable : public Runnable +class TestRuntimeError2Runnable : public Runnable { private: TestMutex* mutex; AbstractQueuedSynchronizerTest* parent; private: - TestInterruptedException2Runnable(const TestInterruptedException2Runnable&); - TestInterruptedException2Runnable operator=( - const TestInterruptedException2Runnable&); + TestRuntimeError2Runnable(const TestRuntimeError2Runnable&); + TestRuntimeError2Runnable operator=(const TestRuntimeError2Runnable&); public: - TestInterruptedException2Runnable(AbstractQueuedSynchronizerTest* parent, - TestMutex* mutex) + TestRuntimeError2Runnable(AbstractQueuedSynchronizerTest* parent, + TestMutex* mutex) : Runnable(), mutex(mutex), parent(parent) { } - virtual ~TestInterruptedException2Runnable() + virtual ~TestRuntimeError2Runnable() { } @@ -606,7 +611,7 @@ class TestInterruptedException2Runnable : public Runnable AbstractQueuedSynchronizerTest::MEDIUM_DELAY_MS * 1000 * 1000); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (activemq::exceptions::InterruptedException& success) { } } @@ -615,12 +620,12 @@ class TestInterruptedException2Runnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(AbstractQueuedSynchronizerTest, testInterruptedException2) +TEST_F(AbstractQueuedSynchronizerTest, testRuntimeError2) { TestMutex mutex; mutex.acquire(1); - TestInterruptedException2Runnable run(this, &mutex); - Thread t(&run); + TestRuntimeError2Runnable run(this, &mutex); + Thread t(&run); try { @@ -891,7 +896,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testAwaitIllegalMonitor) c->await(); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -911,7 +916,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testSignalIllegalMonitor) c->signal(); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -1015,7 +1020,7 @@ class TestAwaitRunnable : public Runnable cond->await(); mutex->release(1); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { parent->threadUnexpectedException(); } @@ -1057,7 +1062,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testHasWaitersNPE) mutex.hasWaiters(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (activemq::exceptions::NullPointerException& success) { } catch (Exception& ex) @@ -1075,7 +1080,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testGetWaitQueueLengthNPE) mutex.getWaitQueueLength(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (activemq::exceptions::NullPointerException& success) { } catch (Exception& ex) @@ -1093,7 +1098,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testGetWaitingThreadsNPE) mutex.getWaitingThreads(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (activemq::exceptions::NullPointerException& success) { } catch (Exception& ex) @@ -1113,7 +1118,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testHasWaitersIAE) mutex2.hasWaiters(c); shouldThrow(); } - catch (IllegalArgumentException& success) + catch (std::invalid_argument& success) { } catch (Exception& ex) @@ -1133,7 +1138,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testHasWaitersIMSE) mutex.hasWaiters(c); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (activemq::exceptions::IllegalMonitorStateException& success) { } catch (Exception& ex) @@ -1154,7 +1159,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testGetWaitQueueLengthIAE) mutex2.getWaitQueueLength(c); shouldThrow(); } - catch (IllegalArgumentException& success) + catch (std::invalid_argument& success) { } catch (Exception& ex) @@ -1174,7 +1179,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testGetWaitQueueLengthIMSE) mutex.getWaitQueueLength(c); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (activemq::exceptions::IllegalMonitorStateException& success) { } catch (Exception& ex) @@ -1195,7 +1200,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testGetWaitingThreadsIAE) mutex2.getWaitingThreads(c); shouldThrow(); } - catch (IllegalArgumentException& success) + catch (std::invalid_argument& success) { } catch (Exception& ex) @@ -1215,7 +1220,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testGetWaitingThreadsIMSE) mutex.getWaitingThreads(c); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (activemq::exceptions::IllegalMonitorStateException& success) { } catch (Exception& ex) @@ -1265,7 +1270,7 @@ class TestHasWaitersRunnable : public Runnable cond->await(); mutex->release(1); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { parent->threadUnexpectedException(); } @@ -1347,7 +1352,7 @@ class testGetWaitQueueLengthRunnable1 : public Runnable cond->await(); mutex->release(1); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { parent->threadUnexpectedException(); } @@ -1392,7 +1397,7 @@ class testGetWaitQueueLengthRunnable2 : public Runnable cond->await(); mutex->release(1); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { parent->threadUnexpectedException(); } @@ -1481,7 +1486,7 @@ class TestGetWaitingThreadsRunnable1 : public Runnable cond->await(); mutex->release(1); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { parent->threadUnexpectedException(); } @@ -1527,7 +1532,7 @@ class TestGetWaitingThreadsRunnable2 : public Runnable cond->await(); mutex->release(1); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { parent->threadUnexpectedException(); } @@ -1704,7 +1709,7 @@ class TestAwaitInterruptRunnable : public Runnable mutex->release(1); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (activemq::exceptions::InterruptedException& success) { } } @@ -1775,7 +1780,7 @@ class TestAwaitNanosInterruptRunnable : public Runnable mutex->release(1); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (activemq::exceptions::InterruptedException& success) { } } @@ -1847,7 +1852,7 @@ class TestAwaitUntilInterruptRunnable : public Runnable mutex->release(1); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (activemq::exceptions::InterruptedException& success) { } } @@ -1915,7 +1920,7 @@ class TestSignalAllRunnable : public Runnable cond->await(); mutex->release(1); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { parent->threadUnexpectedException(); } @@ -2022,7 +2027,7 @@ class TestAcquireSharedInterruptiblyRunnable : public Runnable latch->acquireSharedInterruptibly(0); parent->threadAssertTrue(latch->isSignalled()); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { parent->threadUnexpectedException(); } @@ -2046,7 +2051,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testAcquireSharedInterruptibly) ASSERT_TRUE(l.isSignalled()); t.join(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { unexpectedException(); } @@ -2090,7 +2095,7 @@ class TestAsquireSharedTimedRunnable : public Runnable AbstractQueuedSynchronizerTest::MEDIUM_DELAY_MS * 1000 * 1000)); parent->threadAssertTrue(latch->isSignalled()); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { parent->threadUnexpectedException(); } @@ -2114,7 +2119,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testAsquireSharedTimed) ASSERT_TRUE(l.isSignalled()); t.join(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { unexpectedException(); } @@ -2124,21 +2129,20 @@ TEST_F(AbstractQueuedSynchronizerTest, testAsquireSharedTimed) namespace { -class TestAcquireSharedInterruptiblyInterruptedExceptionRunnable - : public Runnable +class TestAcquireSharedInterruptiblyRuntimeErrorRunnable : public Runnable { private: BooleanLatch* latch; AbstractQueuedSynchronizerTest* parent; private: - TestAcquireSharedInterruptiblyInterruptedExceptionRunnable( - const TestAcquireSharedInterruptiblyInterruptedExceptionRunnable&); - TestAcquireSharedInterruptiblyInterruptedExceptionRunnable operator=( - const TestAcquireSharedInterruptiblyInterruptedExceptionRunnable&); + TestAcquireSharedInterruptiblyRuntimeErrorRunnable( + const TestAcquireSharedInterruptiblyRuntimeErrorRunnable&); + TestAcquireSharedInterruptiblyRuntimeErrorRunnable operator=( + const TestAcquireSharedInterruptiblyRuntimeErrorRunnable&); public: - TestAcquireSharedInterruptiblyInterruptedExceptionRunnable( + TestAcquireSharedInterruptiblyRuntimeErrorRunnable( AbstractQueuedSynchronizerTest* parent, BooleanLatch* latch) : Runnable(), @@ -2147,7 +2151,7 @@ class TestAcquireSharedInterruptiblyInterruptedExceptionRunnable { } - virtual ~TestAcquireSharedInterruptiblyInterruptedExceptionRunnable() + virtual ~TestAcquireSharedInterruptiblyRuntimeErrorRunnable() { } @@ -2159,7 +2163,7 @@ class TestAcquireSharedInterruptiblyInterruptedExceptionRunnable latch->acquireSharedInterruptibly(0); parent->threadShouldThrow(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { } } @@ -2168,11 +2172,11 @@ class TestAcquireSharedInterruptiblyInterruptedExceptionRunnable //////////////////////////////////////////////////////////////////////////////// TEST_F(AbstractQueuedSynchronizerTest, - testAcquireSharedInterruptiblyInterruptedException) + testAcquireSharedInterruptiblyRuntimeError) { - BooleanLatch l; - TestAcquireSharedInterruptiblyInterruptedExceptionRunnable run(this, &l); - Thread t(&run); + BooleanLatch l; + TestAcquireSharedInterruptiblyRuntimeErrorRunnable run(this, &l); + Thread t(&run); t.start(); try @@ -2181,7 +2185,7 @@ TEST_F(AbstractQueuedSynchronizerTest, t.interrupt(); t.join(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { unexpectedException(); } @@ -2191,20 +2195,20 @@ TEST_F(AbstractQueuedSynchronizerTest, namespace { -class TestAcquireSharedNanosInterruptedExceptionRunnable : public Runnable +class TestAcquireSharedNanosRuntimeErrorRunnable : public Runnable { private: BooleanLatch* latch; AbstractQueuedSynchronizerTest* parent; private: - TestAcquireSharedNanosInterruptedExceptionRunnable( - const TestAcquireSharedNanosInterruptedExceptionRunnable&); - TestAcquireSharedNanosInterruptedExceptionRunnable operator=( - const TestAcquireSharedNanosInterruptedExceptionRunnable&); + TestAcquireSharedNanosRuntimeErrorRunnable( + const TestAcquireSharedNanosRuntimeErrorRunnable&); + TestAcquireSharedNanosRuntimeErrorRunnable operator=( + const TestAcquireSharedNanosRuntimeErrorRunnable&); public: - TestAcquireSharedNanosInterruptedExceptionRunnable( + TestAcquireSharedNanosRuntimeErrorRunnable( AbstractQueuedSynchronizerTest* parent, BooleanLatch* latch) : Runnable(), @@ -2213,7 +2217,7 @@ class TestAcquireSharedNanosInterruptedExceptionRunnable : public Runnable { } - virtual ~TestAcquireSharedNanosInterruptedExceptionRunnable() + virtual ~TestAcquireSharedNanosRuntimeErrorRunnable() { } @@ -2227,7 +2231,7 @@ class TestAcquireSharedNanosInterruptedExceptionRunnable : public Runnable AbstractQueuedSynchronizerTest::SMALL_DELAY_MS * 1000 * 1000); parent->threadShouldThrow(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { } } @@ -2235,12 +2239,11 @@ class TestAcquireSharedNanosInterruptedExceptionRunnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(AbstractQueuedSynchronizerTest, - testAcquireSharedNanosInterruptedException) +TEST_F(AbstractQueuedSynchronizerTest, testAcquireSharedNanosRuntimeError) { - BooleanLatch l; - TestAcquireSharedNanosInterruptedExceptionRunnable run(this, &l); - Thread t(&run); + BooleanLatch l; + TestAcquireSharedNanosRuntimeErrorRunnable run(this, &l); + Thread t(&run); t.start(); try @@ -2250,7 +2253,7 @@ TEST_F(AbstractQueuedSynchronizerTest, t.interrupt(); t.join(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { unexpectedException(); } @@ -2294,7 +2297,7 @@ class TestAcquireSharedNanosTimeoutRunnable : public Runnable 0, AbstractQueuedSynchronizerTest::SMALL_DELAY_MS * 1000 * 1000)); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { parent->threadUnexpectedException(); } @@ -2316,7 +2319,7 @@ TEST_F(AbstractQueuedSynchronizerTest, testAcquireSharedNanosTimeout) ASSERT_TRUE(!l.isSignalled()); t.join(); } - catch (InterruptedException& e) + catch (activemq::exceptions::InterruptedException& e) { unexpectedException(); } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantLockTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantLockTest.cpp index f64ae8a73..cc9eb9821 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantLockTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantLockTest.cpp @@ -17,6 +17,8 @@ #include +#include + #include #include #include @@ -29,7 +31,6 @@ using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::locks; @@ -73,7 +74,7 @@ class InterruptibleLockRunnable : public Runnable { lock->lockInterruptibly(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -108,7 +109,7 @@ class InterruptedLockRunnable : public Runnable lock->lockInterruptibly(); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -230,7 +231,7 @@ TEST_F(ReentrantLockTest, testUnlockIllegalMonitorStateException) rl.unlock(); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } } @@ -361,7 +362,7 @@ TEST_F(ReentrantLockTest, testHasQueuedThreadNPE) sync.hasQueuedThread(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (std::logic_error& success) { } } @@ -466,27 +467,25 @@ TEST_F(ReentrantLockTest, testGetQueuedThreads) namespace { -class TestInterruptedException2Runnable : public Runnable +class TestRuntimeError2Runnable : public Runnable { private: ReentrantLock* lock; ReentrantLockTest* parent; private: - TestInterruptedException2Runnable(const TestInterruptedException2Runnable&); - TestInterruptedException2Runnable operator=( - const TestInterruptedException2Runnable&); + TestRuntimeError2Runnable(const TestRuntimeError2Runnable&); + TestRuntimeError2Runnable operator=(const TestRuntimeError2Runnable&); public: - TestInterruptedException2Runnable(ReentrantLock* lock, - ReentrantLockTest* parent) + TestRuntimeError2Runnable(ReentrantLock* lock, ReentrantLockTest* parent) : Runnable(), lock(lock), parent(parent) { } - virtual ~TestInterruptedException2Runnable() + virtual ~TestRuntimeError2Runnable() { } @@ -498,7 +497,7 @@ class TestInterruptedException2Runnable : public Runnable TimeUnit::MILLISECONDS); parent->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -507,13 +506,13 @@ class TestInterruptedException2Runnable : public Runnable } // namespace //////////////////////////////////////////////////////////////////////////////// -TEST_F(ReentrantLockTest, testInterruptedException2) +TEST_F(ReentrantLockTest, testRuntimeError2) { ReentrantLock lock; lock.lock(); - TestInterruptedException2Runnable runnable(&lock, this); - Thread t(&runnable); + TestRuntimeError2Runnable runnable(&lock, this); + Thread t(&runnable); try { @@ -792,7 +791,7 @@ TEST_F(ReentrantLockTest, testAwaitIllegalMonitor) c->await(); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -811,7 +810,7 @@ TEST_F(ReentrantLockTest, testSignalIllegalMonitor) c->signal(); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -952,7 +951,7 @@ TEST_F(ReentrantLockTest, testHasWaitersNPE) lock.hasWaiters(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -970,7 +969,7 @@ TEST_F(ReentrantLockTest, testGetWaitQueueLengthNPE) lock.getWaitQueueLength(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -988,7 +987,7 @@ TEST_F(ReentrantLockTest, testGetWaitingThreadsNPE) lock.getWaitingThreads(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -1008,7 +1007,7 @@ TEST_F(ReentrantLockTest, testHasWaitersIAE) lock2.hasWaiters(c.get()); shouldThrow(); } - catch (IllegalArgumentException& success) + catch (std::invalid_argument& success) { } catch (Exception& ex) @@ -1027,7 +1026,7 @@ TEST_F(ReentrantLockTest, testHasWaitersIMSE) lock.hasWaiters(c.get()); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -1047,7 +1046,7 @@ TEST_F(ReentrantLockTest, testGetWaitQueueLengthIAE) lock2.getWaitQueueLength(c.get()); shouldThrow(); } - catch (IllegalArgumentException& success) + catch (std::invalid_argument& success) { } catch (Exception& ex) @@ -1066,7 +1065,7 @@ TEST_F(ReentrantLockTest, testGetWaitQueueLengthIMSE) lock.getWaitQueueLength(c.get()); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -1086,7 +1085,7 @@ TEST_F(ReentrantLockTest, testGetWaitingThreadsIAE) lock2.getWaitingThreads(c.get()); shouldThrow(); } - catch (IllegalArgumentException& success) + catch (std::invalid_argument& success) { } catch (Exception& ex) @@ -1105,7 +1104,7 @@ TEST_F(ReentrantLockTest, testGetWaitingThreadsIMSE) lock.getWaitingThreads(c.get()); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -1544,7 +1543,7 @@ class TestAwaitInterruptRunnable : public Runnable lock->unlock(); parent->threadShouldThrow(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -1613,7 +1612,7 @@ class TestAwaitNanosInterruptRunnable : public Runnable lock->unlock(); parent->threadShouldThrow(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -1683,7 +1682,7 @@ class TestAwaitUntilInterruptRunnable : public Runnable lock->unlock(); parent->threadShouldThrow(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { } } @@ -1750,7 +1749,7 @@ class TestSignalAllRunnable : public Runnable condition->await(); lock->unlock(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { parent->threadUnexpectedException(); } @@ -1827,7 +1826,7 @@ class TestAwaitLockCountRunnable1 : public Runnable parent->threadAssertEquals(1, lock->getHoldCount()); lock->unlock(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { parent->threadUnexpectedException(); } @@ -1872,7 +1871,7 @@ class TestAwaitLockCountRunnable2 : public Runnable lock->unlock(); lock->unlock(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { parent->threadUnexpectedException(); } diff --git a/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.cpp b/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.cpp index 5345d56c5..8c92f397a 100644 --- a/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.cpp +++ b/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.cpp @@ -17,6 +17,8 @@ #include +#include + #include #include #include @@ -25,7 +27,6 @@ using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::concurrent; using namespace decaf::util::concurrent::locks; @@ -73,7 +74,7 @@ class InterruptibleLockRunnable : public Runnable { lock->writeLock().lockInterruptibly(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -108,7 +109,7 @@ class InterruptedLockRunnable : public Runnable lock->writeLock().lockInterruptibly(); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -227,7 +228,7 @@ TEST_F(ReentrantReadWriteLockTest, testUnlockIllegalMonitorStateException) rl.writeLock().unlock(); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } } @@ -271,7 +272,7 @@ class TestWriteLockInterruptiblyInterruptedRunnable : public Runnable lock->writeLock().lockInterruptibly(); lock->writeLock().unlock(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -336,7 +337,7 @@ class TestWriteTryLockInterruptedRunnable : public Runnable { lock->writeLock().tryLock(1000, TimeUnit::MILLISECONDS); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -401,7 +402,7 @@ class TestReadLockInterruptiblyInterruptedRunnable : public Runnable { lock->readLock().lockInterruptibly(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -468,7 +469,7 @@ class TestReadTryLockInterruptedRunnable : public Runnable lock->readLock().tryLock(1000, TimeUnit::MILLISECONDS); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1639,7 +1640,7 @@ class TestWriteLockInterruptiblyRunnable : public Runnable lock->writeLock().lockInterruptibly(); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1711,7 +1712,7 @@ class TestReadLockInterruptiblyRunnable : public Runnable lock->readLock().lockInterruptibly(); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -1758,7 +1759,7 @@ TEST_F(ReentrantReadWriteLockTest, testAwaitIllegalMonitor) c->await(); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -1777,7 +1778,7 @@ TEST_F(ReentrantReadWriteLockTest, testSignalIllegalMonitor) c->signal(); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -1878,7 +1879,7 @@ class TestAwaitRunnable : public Runnable cond->await(); lock->writeLock().unlock(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { test->threadUnexpectedException(); } @@ -2042,7 +2043,7 @@ class TestAwaitInterruptRunnable : public Runnable lock->writeLock().unlock(); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -2113,7 +2114,7 @@ class TestAwaitNanosInterruptRunnable : public Runnable lock->writeLock().unlock(); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -2183,7 +2184,7 @@ class TestAwaitUntilInterruptRunnable : public Runnable lock->writeLock().unlock(); test->threadShouldThrow(); } - catch (InterruptedException& success) + catch (std::runtime_error& success) { } } @@ -2250,7 +2251,7 @@ class TestSignalAllRunnable : public Runnable cond->await(); lock->writeLock().unlock(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { test->threadUnexpectedException(); } @@ -2329,7 +2330,7 @@ TEST_F(ReentrantReadWriteLockTest, testHasQueuedThreadNPE) sync.hasQueuedThread(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (std::logic_error& success) { } } @@ -2461,7 +2462,7 @@ TEST_F(ReentrantReadWriteLockTest, testHasWaitersNPE) lock.hasWaiters(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -2479,7 +2480,7 @@ TEST_F(ReentrantReadWriteLockTest, testGetWaitQueueLengthNPE) lock.getWaitQueueLength(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -2497,7 +2498,7 @@ TEST_F(ReentrantReadWriteLockTest, testGetWaitingThreadsNPE) lock.getWaitingThreadsPublic(NULL); shouldThrow(); } - catch (NullPointerException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -2517,7 +2518,7 @@ TEST_F(ReentrantReadWriteLockTest, testHasWaitersIAE) lock2.hasWaiters(c.get()); shouldThrow(); } - catch (IllegalArgumentException& success) + catch (std::invalid_argument& success) { } catch (Exception& ex) @@ -2536,7 +2537,7 @@ TEST_F(ReentrantReadWriteLockTest, testHasWaitersIMSE) lock.hasWaiters(c.get()); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -2556,7 +2557,7 @@ TEST_F(ReentrantReadWriteLockTest, testGetWaitQueueLengthIAE) lock2.getWaitQueueLength(c.get()); shouldThrow(); } - catch (IllegalArgumentException& success) + catch (std::invalid_argument& success) { } catch (Exception& ex) @@ -2575,7 +2576,7 @@ TEST_F(ReentrantReadWriteLockTest, testGetWaitQueueLengthIMSE) lock.getWaitQueueLength(c.get()); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -2595,7 +2596,7 @@ TEST_F(ReentrantReadWriteLockTest, testGetWaitingThreadsIAE) lock2.getWaitingThreadsPublic(c.get()); shouldThrow(); } - catch (IllegalArgumentException& success) + catch (std::invalid_argument& success) { } catch (Exception& ex) @@ -2614,7 +2615,7 @@ TEST_F(ReentrantReadWriteLockTest, testGetWaitingThreadsIMSE) lock.getWaitingThreadsPublic(c.get()); shouldThrow(); } - catch (IllegalMonitorStateException& success) + catch (std::logic_error& success) { } catch (Exception& ex) @@ -2663,7 +2664,7 @@ class TestHasWaitersRunnable : public Runnable cond->await(); lock->writeLock().unlock(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { test->threadUnexpectedException(); } @@ -2743,7 +2744,7 @@ class TestGetWaitQueueLengthRunnable : public Runnable cond->await(); lock->writeLock().unlock(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { test->threadUnexpectedException(); } @@ -2824,7 +2825,7 @@ class TestGetWaitingThreadsRunnable1 : public Runnable cond->await(); lock->writeLock().unlock(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { test->threadUnexpectedException(); } @@ -2869,7 +2870,7 @@ class TestGetWaitingThreadsRunnable2 : public Runnable cond->await(); lock->writeLock().unlock(); } - catch (InterruptedException& e) + catch (std::runtime_error& e) { test->threadUnexpectedException(); } diff --git a/activemq-cpp/src/test/decaf/util/zip/Adler32Test.cpp b/activemq-cpp/src/test/decaf/util/zip/Adler32Test.cpp index ec976cff6..68aadf092 100644 --- a/activemq-cpp/src/test/decaf/util/zip/Adler32Test.cpp +++ b/activemq-cpp/src/test/decaf/util/zip/Adler32Test.cpp @@ -27,7 +27,6 @@ using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -159,11 +158,9 @@ TEST_F(Adler32Test, testUpdateArrayIndexed) << ("update(unsigned char[],int,int) failed to update the checksum to " "the correct value "); - ASSERT_THROW(adl.update(byteArray, SIZE, off, lenError), - IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException for lenError"); + ASSERT_THROW(adl.update(byteArray, SIZE, off, lenError), std::out_of_range) + << ("Should have thrown an std::out_of_range for lenError"); - ASSERT_THROW(adl.update(byteArray, SIZE, offError, len), - IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException for offError"); + ASSERT_THROW(adl.update(byteArray, SIZE, offError, len), std::out_of_range) + << ("Should have thrown an std::out_of_range for offError"); } diff --git a/activemq-cpp/src/test/decaf/util/zip/CRC32Test.cpp b/activemq-cpp/src/test/decaf/util/zip/CRC32Test.cpp index a46cbd5b8..f8d6bb998 100644 --- a/activemq-cpp/src/test/decaf/util/zip/CRC32Test.cpp +++ b/activemq-cpp/src/test/decaf/util/zip/CRC32Test.cpp @@ -26,7 +26,6 @@ using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -179,11 +178,9 @@ TEST_F(CRC32Test, testUpdateArrayIndexed) << ("update(unsigned char[],int,int) failed to update the checksum to " "the correct value "); - ASSERT_THROW(crc.update(byteArray, SIZE, off, lenError), - IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException for lenError"); + ASSERT_THROW(crc.update(byteArray, SIZE, off, lenError), std::out_of_range) + << ("Should have thrown an std::out_of_range for lenError"); - ASSERT_THROW(crc.update(byteArray, SIZE, offError, len), - IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException for offError"); + ASSERT_THROW(crc.update(byteArray, SIZE, offError, len), std::out_of_range) + << ("Should have thrown an std::out_of_range for offError"); } diff --git a/activemq-cpp/src/test/decaf/util/zip/CheckedInputStreamTest.cpp b/activemq-cpp/src/test/decaf/util/zip/CheckedInputStreamTest.cpp index e908593ba..44837fbb8 100644 --- a/activemq-cpp/src/test/decaf/util/zip/CheckedInputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/util/zip/CheckedInputStreamTest.cpp @@ -31,7 +31,6 @@ using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; diff --git a/activemq-cpp/src/test/decaf/util/zip/CheckedOutputStreamTest.cpp b/activemq-cpp/src/test/decaf/util/zip/CheckedOutputStreamTest.cpp index da11f49c0..74f34a0ce 100644 --- a/activemq-cpp/src/test/decaf/util/zip/CheckedOutputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/util/zip/CheckedOutputStreamTest.cpp @@ -26,7 +26,6 @@ using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -115,6 +114,6 @@ TEST_F(CheckedOutputStreamTest, testWriteBIII) << ("the checkSum value is zero, no bytes are written to the output " "file"); - ASSERT_THROW(chkOut.write(byteArray, SIZE, 4, 6), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(chkOut.write(byteArray, SIZE, 4, 6), std::out_of_range) + << ("Should have thrown an std::out_of_range"); } diff --git a/activemq-cpp/src/test/decaf/util/zip/DeflaterOutputStreamTest.cpp b/activemq-cpp/src/test/decaf/util/zip/DeflaterOutputStreamTest.cpp index c18dd0b55..2fe3f9fd3 100644 --- a/activemq-cpp/src/test/decaf/util/zip/DeflaterOutputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/util/zip/DeflaterOutputStreamTest.cpp @@ -30,7 +30,7 @@ #include -#include +#include #include @@ -38,7 +38,6 @@ using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -159,8 +158,8 @@ TEST_F(DeflaterOutputStreamTest, testConstructorOutputStreamDeflater) ByteArrayOutputStream baos; Deflater* nullDeflater = NULL; - ASSERT_THROW(DeflaterOutputStream(&baos, nullDeflater), NullPointerException) - << ("Should have thrown a NullPointerException"); + ASSERT_THROW(DeflaterOutputStream(&baos, nullDeflater), std::logic_error) + << ("Should have thrown std::logic_error"); Deflater defl; MyDeflaterOutputStream dos(&baos, &defl); @@ -199,14 +198,14 @@ TEST_F(DeflaterOutputStreamTest, testConstructorOutputStreamDeflaterI) // Test for a null Deflater. ASSERT_THROW(DeflaterOutputStream(&baos, nullDeflater, buf), - NullPointerException) - << ("Should have thrown a NullPointerException"); + std::logic_error) + << ("Should have thrown std::logic_error"); Deflater defl; // Test for a zero buf. ASSERT_THROW(DeflaterOutputStream(&baos, &defl, zeroBuf), - IllegalArgumentException) + std::invalid_argument) << ("Should have thrown a IllegalArgumentException"); // Test to see if DeflaterOutputStream was created with the correct @@ -312,13 +311,13 @@ TEST_F(DeflaterOutputStreamTest, testWriteBIII) ByteArrayOutputStream baos2; DeflaterOutputStream dos2(&baos2); - ASSERT_THROW(dos2.write(byteArray, 7, 2, 10), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(dos2.write(byteArray, 7, 2, 10), std::out_of_range) + << ("Should have thrown an std::out_of_range"); // Test for trying to start writing from a unsigned char > than the array // size. - ASSERT_THROW(dos2.write(byteArray, 7, 2, 10), IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + ASSERT_THROW(dos2.write(byteArray, 7, 2, 10), std::out_of_range) + << ("Should have thrown an std::out_of_range"); dos2.close(); } diff --git a/activemq-cpp/src/test/decaf/util/zip/DeflaterTest.cpp b/activemq-cpp/src/test/decaf/util/zip/DeflaterTest.cpp index 7b4d9b10d..5fe121d8f 100644 --- a/activemq-cpp/src/test/decaf/util/zip/DeflaterTest.cpp +++ b/activemq-cpp/src/test/decaf/util/zip/DeflaterTest.cpp @@ -24,8 +24,6 @@ #include -#include - #include #ifdef HAVE_STDLIB_H @@ -38,12 +36,12 @@ #include #endif +#include #include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -204,8 +202,8 @@ TEST_F(DeflaterTest, testDeflateArray) } ASSERT_THROW(deflater.deflate(outPutBuf2, SIZE, offSet, length), - IndexOutOfBoundsException) - << ("Should have thrown an IndexOutOfBoundsException"); + std::out_of_range) + << ("Should have thrown an std::out_of_range"); } defl.end(); @@ -556,7 +554,7 @@ TEST_F(DeflaterTest, testSetDictionaryBIII) Integer::toString(offSet) + " and length " + Integer::toString(length)); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { } } @@ -676,7 +674,7 @@ TEST_F(DeflaterTest, testSetInputBIII) Integer::toString(offSet) + " and length " + Integer::toString(length)); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { } } @@ -734,11 +732,11 @@ TEST_F(DeflaterTest, testSetLevel) Deflater boundDefl; // testing boundaries - ASSERT_THROW(boundDefl.setLevel(-2), IllegalArgumentException) + ASSERT_THROW(boundDefl.setLevel(-2), std::invalid_argument) << ("IllegalArgumentException not thrown when setting level to a " "number < 0."); - ASSERT_THROW(boundDefl.setLevel(10), IllegalArgumentException) + ASSERT_THROW(boundDefl.setLevel(10), std::invalid_argument) << ("IllegalArgumentException not thrown when setting level to a " "number > 9."); } @@ -806,7 +804,7 @@ TEST_F(DeflaterTest, testSetStrategy) Deflater boundDefl; // testing boundaries - ASSERT_THROW(boundDefl.setStrategy(424), IllegalArgumentException) + ASSERT_THROW(boundDefl.setStrategy(424), std::invalid_argument) << ("IllegalArgumentException not thrown when setting strategy to an " "invalid value."); } @@ -956,11 +954,11 @@ TEST_F(DeflaterTest, testConstructorIB) Deflater boundDefl; // testing boundaries - ASSERT_THROW(boundDefl.setLevel(-2), IllegalArgumentException) + ASSERT_THROW(boundDefl.setLevel(-2), std::invalid_argument) << ("IllegalArgumentException not thrown when setting level to a " "number < 0."); - ASSERT_THROW(boundDefl.setLevel(10), IllegalArgumentException) + ASSERT_THROW(boundDefl.setLevel(10), std::invalid_argument) << ("IllegalArgumentException not thrown when setting level to a " "number > 9."); } @@ -1014,11 +1012,11 @@ TEST_F(DeflaterTest, testConstructorI) Deflater boundDefl; // testing boundaries - ASSERT_THROW(boundDefl.setLevel(-2), IllegalArgumentException) + ASSERT_THROW(boundDefl.setLevel(-2), std::invalid_argument) << ("IllegalArgumentException not thrown when setting level to a " "number < 0."); - ASSERT_THROW(boundDefl.setLevel(10), IllegalArgumentException) + ASSERT_THROW(boundDefl.setLevel(10), std::invalid_argument) << ("IllegalArgumentException not thrown when setting level to a " "number > 9."); } @@ -1029,34 +1027,34 @@ void DeflaterTest::helperEndTest(Deflater& defl, const std::string& desc) // Help tests for test_end() and test_reset(). unsigned char byteArray[] = {5, 2, 3, 7, 8}; - // Methods where we expect IllegalStateException or NullPointerException + // Methods where we expect std::logic_error or std::logic_error // to be thrown - ASSERT_THROW(defl.getBytesWritten(), IllegalStateException) + ASSERT_THROW(defl.getBytesWritten(), std::logic_error) << (std::string() + "defl.getBytesWritten() can still be used after " + desc + " is called in test_" + desc); - ASSERT_THROW(defl.getAdler(), IllegalStateException) + ASSERT_THROW(defl.getAdler(), std::logic_error) << (std::string() + "defl.getAdler() can still be used after " + desc + " is called in test_" + desc); - ASSERT_THROW(defl.getBytesRead(), IllegalStateException) + ASSERT_THROW(defl.getBytesRead(), std::logic_error) << (std::string() + "defl.getBytesRead() can still be used after " + desc + " is called in test_" + desc); unsigned char dict[] = {'a', 'b', 'c'}; - ASSERT_THROW(defl.setDictionary(dict, 3, 0, 3), IllegalStateException) + ASSERT_THROW(defl.setDictionary(dict, 3, 0, 3), std::logic_error) << (std::string() + "defl.setDictionary() can still be used after " + desc + " is called in test_" + desc); - ASSERT_THROW(defl.deflate(byteArray, 5, 0, 5), IllegalStateException) + ASSERT_THROW(defl.deflate(byteArray, 5, 0, 5), std::logic_error) << (std::string() + "defl.deflate() can still be used after " + desc + " is called in test_" + desc); - ASSERT_THROW(defl.setInput(byteArray, 5, 0, 5), IllegalStateException) + ASSERT_THROW(defl.setInput(byteArray, 5, 0, 5), std::logic_error) << (std::string() + "defl.setInput() can still be used after " + desc + " is called in test_" + desc); - ASSERT_THROW(defl.reset(), IllegalStateException) + ASSERT_THROW(defl.reset(), std::logic_error) << (std::string() + "defl.reset() can still be used after " + desc + " is called in test_" + desc); diff --git a/activemq-cpp/src/test/decaf/util/zip/InflaterInputStreamTest.cpp b/activemq-cpp/src/test/decaf/util/zip/InflaterInputStreamTest.cpp index 2d4b44777..a199beb63 100644 --- a/activemq-cpp/src/test/decaf/util/zip/InflaterInputStreamTest.cpp +++ b/activemq-cpp/src/test/decaf/util/zip/InflaterInputStreamTest.cpp @@ -30,15 +30,12 @@ #include -#include - #include using namespace std; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -74,13 +71,11 @@ const std::string InflaterInputStreamTest::testString = "PrintStream\n" "Test_java_io_RandomAccessFile\nTest_java_io_SyncFailedException\nTest_" "java_lang_AbstractMethodError\n" - "Test_java_lang_ArithmeticException\nTest_java_lang_" - "ArrayIndexOutOfBoundsException\n" + "Test_java_lang_ArithmeticException\n" "Test_java_lang_ArrayStoreException\nTest_java_lang_Boolean\nTest_java_" "lang_Byte\n" "Test_java_lang_Character\nTest_java_lang_Class\nTest_java_lang_" - "ClassCastException\n" - "Test_java_lang_ClassCircularityError\nTest_java_lang_ClassFormatError\n" + "ClassCircularityError\nTest_java_lang_ClassFormatError\n" "Test_java_lang_ClassLoader\nTest_java_lang_ClassNotFoundException\n" "Test_java_lang_CloneNotSupportedException\nTest_java_lang_Double\nTest_" "java_lang_Error\n" @@ -88,21 +83,20 @@ const std::string InflaterInputStreamTest::testString = "ExceptionInInitializerError\nTest_java_lang_Float\n" "Test_java_lang_IllegalAccessError\nTest_java_lang_IllegalAccessException\n" "Test_java_lang_IllegalArgumentException\nTest_java_lang_" - "IllegalMonitorStateException\n" + "" "Test_java_lang_IllegalThreadStateException\nTest_java_lang_" "IncompatibleClassChangeError\n" "Test_java_lang_IndexOutOfBoundsException\nTest_java_lang_" "InstantiationError\n" "Test_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_" "lang_InternalError\n" - "Test_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_" + "Test_java_lang_RuntimeError\nTest_java_lang_LinkageError\nTest_" "java_lang_Long\n" "Test_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_" "lang_NoClassDefFoundError\n" "Test_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\n" "Test_java_lang_NullPointerException\nTest_java_lang_Number\nTest_java_" - "lang_NumberFormatException\n" - "Test_java_lang_Object\nTest_java_lang_OutOfMemoryError\nTest_java_lang_" + "lang_Object\nTest_java_lang_OutOfMemoryError\nTest_java_lang_" "RuntimeException\n" "Test_java_lang_SecurityManager\nTest_java_lang_Short\nTest_java_lang_" "StackOverflowError\n" diff --git a/activemq-cpp/src/test/decaf/util/zip/InflaterTest.cpp b/activemq-cpp/src/test/decaf/util/zip/InflaterTest.cpp index a05497b81..00531ea59 100644 --- a/activemq-cpp/src/test/decaf/util/zip/InflaterTest.cpp +++ b/activemq-cpp/src/test/decaf/util/zip/InflaterTest.cpp @@ -21,13 +21,13 @@ #include #include #include +#include #include using namespace std; using namespace decaf; using namespace decaf::lang; -using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::util::zip; @@ -77,7 +77,7 @@ TEST_F(InflaterTest, testEnd) inflate.reset(); inflate.setInput(byteArray, 5, 0, 5); } - catch (IllegalStateException& e) + catch (std::logic_error& e) { r = 1; } @@ -485,7 +485,7 @@ TEST_F(InflaterTest, testInflateBII) { FAIL() << ("Invalid input to be decompressed"); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { r = 1; } @@ -854,7 +854,7 @@ TEST_F(InflaterTest, testSetInputBIII) { inflate.setInput(byteArray, SIZE, 100, 100); } - catch (IndexOutOfBoundsException& e) + catch (std::out_of_range& e) { r = 1; } @@ -1073,7 +1073,7 @@ TEST_F(InflaterTest, testSetDictionaryB) Inflater infl1; inflNo.setInput(outputNo, 0, dataLenNo); - ASSERT_THROW(infl1.setDictionary(dictionary1), IllegalArgumentException) + ASSERT_THROW(infl1.setDictionary(dictionary1), std::invalid_argument) << ("IllegalArgumentException expected."); inflNo.end(); @@ -1083,7 +1083,7 @@ TEST_F(InflaterTest, testSetDictionaryB) ASSERT_TRUE(infl1.needsDictionary()); - ASSERT_THROW(infl1.setDictionary(dictionary2), IllegalArgumentException) + ASSERT_THROW(infl1.setDictionary(dictionary2), std::invalid_argument) << ("IllegalArgumentException expected."); infl1.end(); @@ -1184,7 +1184,7 @@ TEST_F(InflaterTest, testSetDictionaryBIII) decLen = infl2.inflate(result); ASSERT_TRUE(infl2.needsDictionary()); - ASSERT_THROW(infl2.setDictionary(dictionary1), IllegalArgumentException) + ASSERT_THROW(infl2.setDictionary(dictionary1), std::invalid_argument) << ("IllegalArgumentException expected."); infl2.end(); From 836d085ab38e9b145d9ad6e9e085b44996ad8b8b Mon Sep 17 00:00:00 2001 From: ZafrulLipu Date: Thu, 14 May 2026 19:14:14 +0700 Subject: [PATCH 2/2] change signature --- .../tool/commands/MessageSourceGenerator.java | 14 ++-- .../AmqCppMarshallingClassesGenerator.java | 36 ++++++---- .../src/main/activemq/cmsutil/CmsTemplate.cpp | 3 +- .../cmsutil/DynamicDestinationResolver.cpp | 7 +- .../main/activemq/cmsutil/PooledSession.cpp | 7 +- .../activemq/commands/ActiveMQMapMessage.cpp | 9 +-- .../commands/ActiveMQStreamMessage.cpp | 22 +++--- .../src/main/activemq/commands/Message.cpp | 11 ++- .../main/activemq/commands/WireFormatInfo.cpp | 16 +++-- .../main/activemq/exceptions/IoCatchMacros.h | 8 +++ .../main/activemq/util/CMSExceptionSupport.h | 6 ++ .../wireformat/openwire/OpenWireFormat.cpp | 70 +++++++++---------- .../marshal/BaseDataStreamMarshaller.h | 2 +- .../marshal/OpenWireMarshalCatchMacros.h | 57 +++++++++++++++ .../ActiveMQBlobMessageMarshaller.cpp | 36 ++++++---- .../ActiveMQBytesMessageMarshaller.cpp | 36 ++++++---- .../ActiveMQDestinationMarshaller.cpp | 36 ++++++---- .../ActiveMQMapMessageMarshaller.cpp | 36 ++++++---- .../generated/ActiveMQMessageMarshaller.cpp | 36 ++++++---- .../ActiveMQObjectMessageMarshaller.cpp | 36 ++++++---- .../generated/ActiveMQQueueMarshaller.cpp | 36 ++++++---- .../ActiveMQStreamMessageMarshaller.cpp | 36 ++++++---- .../ActiveMQTempDestinationMarshaller.cpp | 36 ++++++---- .../generated/ActiveMQTempQueueMarshaller.cpp | 36 ++++++---- .../generated/ActiveMQTempTopicMarshaller.cpp | 36 ++++++---- .../ActiveMQTextMessageMarshaller.cpp | 36 ++++++---- .../generated/ActiveMQTopicMarshaller.cpp | 36 ++++++---- .../generated/BaseCommandMarshaller.cpp | 36 ++++++---- .../marshal/generated/BrokerIdMarshaller.cpp | 36 ++++++---- .../generated/BrokerInfoMarshaller.cpp | 36 ++++++---- .../generated/ConnectionControlMarshaller.cpp | 36 ++++++---- .../generated/ConnectionErrorMarshaller.cpp | 36 ++++++---- .../generated/ConnectionIdMarshaller.cpp | 36 ++++++---- .../generated/ConnectionInfoMarshaller.cpp | 36 ++++++---- .../generated/ConsumerControlMarshaller.cpp | 36 ++++++---- .../generated/ConsumerIdMarshaller.cpp | 36 ++++++---- .../generated/ConsumerInfoMarshaller.cpp | 36 ++++++---- .../generated/ControlCommandMarshaller.cpp | 36 ++++++---- .../generated/DataArrayResponseMarshaller.cpp | 36 ++++++---- .../generated/DataResponseMarshaller.cpp | 36 ++++++---- .../generated/DestinationInfoMarshaller.cpp | 36 ++++++---- .../generated/DiscoveryEventMarshaller.cpp | 36 ++++++---- .../generated/ExceptionResponseMarshaller.cpp | 36 ++++++---- .../generated/FlushCommandMarshaller.cpp | 36 ++++++---- .../generated/IntegerResponseMarshaller.cpp | 36 ++++++---- .../generated/JournalQueueAckMarshaller.cpp | 36 ++++++---- .../generated/JournalTopicAckMarshaller.cpp | 36 ++++++---- .../generated/JournalTraceMarshaller.cpp | 36 ++++++---- .../JournalTransactionMarshaller.cpp | 36 ++++++---- .../generated/KeepAliveInfoMarshaller.cpp | 36 ++++++---- .../LastPartialCommandMarshaller.cpp | 36 ++++++---- .../LocalTransactionIdMarshaller.cpp | 36 ++++++---- .../generated/MessageAckMarshaller.cpp | 36 ++++++---- .../generated/MessageDispatchMarshaller.cpp | 36 ++++++---- .../MessageDispatchNotificationMarshaller.cpp | 36 ++++++---- .../marshal/generated/MessageIdMarshaller.cpp | 36 ++++++---- .../marshal/generated/MessageMarshaller.cpp | 36 ++++++---- .../generated/MessagePullMarshaller.cpp | 36 ++++++---- .../NetworkBridgeFilterMarshaller.cpp | 36 ++++++---- .../generated/PartialCommandMarshaller.cpp | 36 ++++++---- .../generated/ProducerAckMarshaller.cpp | 36 ++++++---- .../generated/ProducerIdMarshaller.cpp | 36 ++++++---- .../generated/ProducerInfoMarshaller.cpp | 36 ++++++---- .../generated/RemoveInfoMarshaller.cpp | 36 ++++++---- .../RemoveSubscriptionInfoMarshaller.cpp | 36 ++++++---- .../generated/ReplayCommandMarshaller.cpp | 36 ++++++---- .../marshal/generated/ResponseMarshaller.cpp | 36 ++++++---- .../marshal/generated/SessionIdMarshaller.cpp | 36 ++++++---- .../generated/SessionInfoMarshaller.cpp | 36 ++++++---- .../generated/ShutdownInfoMarshaller.cpp | 36 ++++++---- .../generated/SubscriptionInfoMarshaller.cpp | 36 ++++++---- .../generated/TransactionIdMarshaller.cpp | 36 ++++++---- .../generated/TransactionInfoMarshaller.cpp | 36 ++++++---- .../generated/WireFormatInfoMarshaller.cpp | 36 ++++++---- .../generated/XATransactionIdMarshaller.cpp | 36 ++++++---- .../activemq/wireformat/stomp/StompFrame.cpp | 37 +++++----- .../wireformat/stomp/StompWireFormat.cpp | 16 +++-- .../activemq/util/AdvisorySupportTest.cpp | 2 +- 78 files changed, 1486 insertions(+), 1033 deletions(-) create mode 100644 activemq-cpp/src/main/activemq/wireformat/openwire/marshal/OpenWireMarshalCatchMacros.h diff --git a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/MessageSourceGenerator.java b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/MessageSourceGenerator.java index 5a1e971d1..ba95fc10d 100644 --- a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/MessageSourceGenerator.java +++ b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/commands/MessageSourceGenerator.java @@ -118,9 +118,10 @@ protected void generateAdditionalMethods( PrintWriter out ) { out.println(" &properties, marshalledProperties );"); out.println(" }"); out.println(" }"); - out.println(" AMQ_IOSTREAM_CATCH_RETHROW()"); - out.println(" AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION()"); - out.println(" AMQ_IOSTREAM_CATCHALL_THROW()"); + out.println(" AMQ_CATCH_RETHROW(activemq::exceptions::IOException)"); + out.println(" AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception,"); + out.println(" activemq::exceptions::IOException)"); + out.println(" AMQ_CATCHALL_THROW(activemq::exceptions::IOException)"); out.println("}"); out.println(""); out.println("////////////////////////////////////////////////////////////////////////////////"); @@ -130,9 +131,10 @@ protected void generateAdditionalMethods( PrintWriter out ) { out.println(" wireformat::openwire::marshal::PrimitiveTypesMarshaller::unmarshal("); out.println(" &properties, marshalledProperties);"); out.println(" }"); - out.println(" AMQ_IOSTREAM_CATCH_RETHROW()"); - out.println(" AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION()"); - out.println(" AMQ_IOSTREAM_CATCHALL_THROW()"); + out.println(" AMQ_CATCH_RETHROW(activemq::exceptions::IOException)"); + out.println(" AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception,"); + out.println(" activemq::exceptions::IOException)"); + out.println(" AMQ_CATCHALL_THROW(activemq::exceptions::IOException)"); out.println("}"); out.println(""); } diff --git a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingClassesGenerator.java b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingClassesGenerator.java index 87d100058..4b18098b6 100644 --- a/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingClassesGenerator.java +++ b/activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingClassesGenerator.java @@ -572,6 +572,7 @@ protected void generateFile(PrintWriter out) throws Exception { out.println(""); out.println("#include "); out.println("#include "); +out.println("#include "); out.println("#include "); out.println(""); out.println("//"); @@ -645,9 +646,10 @@ protected void generateFile(PrintWriter out) throws Exception { } out.println(" }"); -out.println(" AMQ_IOSTREAM_CATCH_RETHROW()" ); -out.println(" AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION()" ); -out.println(" AMQ_IOSTREAM_CATCHALL_THROW()" ); +out.println(" AMQ_CATCH_RETHROW(activemq::exceptions::IOException)" ); +out.println(" AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException," ); +out.println(" activemq::exceptions::IOException)" ); +out.println(" AMQ_CATCHALL_THROW(activemq::exceptions::IOException)" ); out.println("}"); out.println(""); out.println("///////////////////////////////////////////////////////////////////////////////"); @@ -680,9 +682,10 @@ protected void generateFile(PrintWriter out) throws Exception { out.println(""); out.println(" return rc + "+baseSize+";"); out.println(" }"); -out.println(" AMQ_IOSTREAM_CATCH_RETHROW()" ); -out.println(" AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION()" ); -out.println(" AMQ_IOSTREAM_CATCHALL_THROW()" ); +out.println(" AMQ_CATCH_RETHROW(activemq::exceptions::IOException)" ); +out.println(" AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException," ); +out.println(" activemq::exceptions::IOException)" ); +out.println(" AMQ_CATCHALL_THROW(activemq::exceptions::IOException)" ); out.println("}"); out.println(""); out.println("///////////////////////////////////////////////////////////////////////////////"); @@ -712,9 +715,10 @@ protected void generateFile(PrintWriter out) throws Exception { } out.println(" }"); -out.println(" AMQ_IOSTREAM_CATCH_RETHROW()" ); -out.println(" AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION()" ); -out.println(" AMQ_IOSTREAM_CATCHALL_THROW()" ); +out.println(" AMQ_CATCH_RETHROW(activemq::exceptions::IOException)" ); +out.println(" AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException," ); +out.println(" activemq::exceptions::IOException)" ); +out.println(" AMQ_CATCHALL_THROW(activemq::exceptions::IOException)" ); out.println("}"); out.println(""); out.println("///////////////////////////////////////////////////////////////////////////////"); @@ -747,9 +751,10 @@ protected void generateFile(PrintWriter out) throws Exception { } out.println(" }"); -out.println(" AMQ_IOSTREAM_CATCH_RETHROW()" ); -out.println(" AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION()" ); -out.println(" AMQ_IOSTREAM_CATCHALL_THROW()" ); +out.println(" AMQ_CATCH_RETHROW(activemq::exceptions::IOException)" ); +out.println(" AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException," ); +out.println(" activemq::exceptions::IOException)" ); +out.println(" AMQ_CATCHALL_THROW(activemq::exceptions::IOException)" ); out.println("}"); out.println(""); out.println("///////////////////////////////////////////////////////////////////////////////"); @@ -783,9 +788,10 @@ protected void generateFile(PrintWriter out) throws Exception { } out.println(" }"); -out.println(" AMQ_IOSTREAM_CATCH_RETHROW()" ); -out.println(" AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION()" ); -out.println(" AMQ_IOSTREAM_CATCHALL_THROW()" ); +out.println(" AMQ_CATCH_RETHROW(activemq::exceptions::IOException)" ); +out.println(" AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException," ); +out.println(" activemq::exceptions::IOException)" ); +out.println(" AMQ_CATCHALL_THROW(activemq::exceptions::IOException)" ); out.println("}"); out.println(""); } diff --git a/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp b/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp index 5f82f1eac..ab145087c 100644 --- a/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp +++ b/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp @@ -250,7 +250,8 @@ void CmsTemplate::checkDefaultDestination() { throw IllegalStateException( "No defaultDestination or defaultDestinationName specified." - "Check configuration of CmsTemplate."); + "Check configuration of CmsTemplate.", + NULL); } } diff --git a/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp b/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp index bd2ef6acf..df490df4e 100644 --- a/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp +++ b/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp @@ -21,7 +21,6 @@ #include using namespace activemq::cmsutil; -using namespace activemq::exceptions; using namespace decaf::util; using namespace cms; using namespace std; @@ -36,7 +35,7 @@ cms::Topic* DynamicDestinationResolver::SessionResolver::getTopic( // See if we already have a topic with this name. topic = topicMap.get(topicName); } - catch (NoSuchElementException&) + catch (activemq::exceptions::NoSuchElementException&) { // Create a new topic. topic = session->createTopic(topicName); @@ -60,7 +59,7 @@ cms::Queue* DynamicDestinationResolver::SessionResolver::getQueue( // See if we already have a queue with this name. queue = queueMap.get(queueName); } - catch (NoSuchElementException&) + catch (activemq::exceptions::NoSuchElementException&) { // Create a new queue. queue = session->createQueue(queueName); @@ -119,7 +118,7 @@ cms::Destination* DynamicDestinationResolver::resolveDestinationName( { resolver = sessionResolverMap.get(session); } - catch (NoSuchElementException&) + catch (activemq::exceptions::NoSuchElementException&) { resolver = new SessionResolver(session, resourceLifecycleManager); sessionResolverMap.put(session, resolver); diff --git a/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp b/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp index 63fd3bc2d..1a28bda48 100644 --- a/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp +++ b/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp @@ -29,7 +29,6 @@ using namespace cms; using namespace decaf::util; using namespace activemq::cmsutil; -using namespace activemq::exceptions; /** * A catch-all that throws an CMSException. @@ -126,7 +125,7 @@ cms::MessageProducer* PooledSession::createCachedProducer( { cachedProducer = producerCache.get(key); } - catch (NoSuchElementException&) + catch (activemq::exceptions::NoSuchElementException&) { // No producer exists for this destination - start by creating // a new producer resource. @@ -173,9 +172,9 @@ cms::MessageConsumer* PooledSession::createCachedConsumer( { cachedConsumer = consumerCache.get(key); } - catch (NoSuchElementException&) + catch (activemq::exceptions::NoSuchElementException&) { - // No producer exists for this destination - start by creating + // No consumer exists for this destination - start by creating // a new consumer resource. cms::MessageConsumer* c = session->createConsumer(destination, selector, noLocal); diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp b/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp index 2af148ea5..bc9451e41 100644 --- a/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp +++ b/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -155,9 +155,10 @@ void ActiveMQMapMessage::beforeMarshal(WireFormat* wireFormat) clearBody(); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp b/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp index e0411d425..48ac2349b 100644 --- a/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp +++ b/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp @@ -262,7 +262,7 @@ bool ActiveMQStreamMessage::readBoolean() const } catch (activemq::exceptions::IllegalStateException& e) { - throw CMSException(e.what(), NULL); + throw cms::IllegalStateException(e.what()); } catch (cms::CMSException&) { @@ -345,7 +345,7 @@ unsigned char ActiveMQStreamMessage::readByte() const } catch (activemq::exceptions::IllegalStateException& e) { - throw CMSException(e.what(), NULL); + throw cms::IllegalStateException(e.what()); } catch (cms::CMSException&) { @@ -441,7 +441,7 @@ int ActiveMQStreamMessage::readBytes(unsigned char* buffer, int length) const else { // big buffer - int rc = this->dataIn->read(buffer, + int rc = this->dataIn->read(buffer, length, 0, this->impl->remainingBytes); @@ -459,7 +459,7 @@ int ActiveMQStreamMessage::readBytes(unsigned char* buffer, int length) const } catch (activemq::exceptions::IllegalStateException& e) { - throw CMSException(e.what(), NULL); + throw cms::IllegalStateException(e.what()); } catch (cms::CMSException&) { @@ -541,7 +541,7 @@ char ActiveMQStreamMessage::readChar() const } catch (activemq::exceptions::IllegalStateException& e) { - throw CMSException(e.what(), NULL); + throw cms::IllegalStateException(e.what()); } catch (cms::CMSException&) { @@ -624,7 +624,7 @@ float ActiveMQStreamMessage::readFloat() const } catch (activemq::exceptions::IllegalStateException& e) { - throw CMSException(e.what(), NULL); + throw cms::IllegalStateException(e.what()); } catch (cms::CMSException&) { @@ -711,7 +711,7 @@ double ActiveMQStreamMessage::readDouble() const } catch (activemq::exceptions::IllegalStateException& e) { - throw CMSException(e.what(), NULL); + throw cms::IllegalStateException(e.what()); } catch (cms::CMSException&) { @@ -798,7 +798,7 @@ short ActiveMQStreamMessage::readShort() const } catch (activemq::exceptions::IllegalStateException& e) { - throw CMSException(e.what(), NULL); + throw cms::IllegalStateException(e.what()); } catch (cms::CMSException&) { @@ -886,7 +886,7 @@ unsigned short ActiveMQStreamMessage::readUnsignedShort() const } catch (activemq::exceptions::IllegalStateException& e) { - throw CMSException(e.what(), NULL); + throw cms::IllegalStateException(e.what()); } catch (cms::CMSException&) { @@ -977,7 +977,7 @@ int ActiveMQStreamMessage::readInt() const } catch (activemq::exceptions::IllegalStateException& e) { - throw CMSException(e.what(), NULL); + throw cms::IllegalStateException(e.what()); } catch (cms::CMSException&) { @@ -1072,7 +1072,7 @@ long long ActiveMQStreamMessage::readLong() const } catch (activemq::exceptions::IllegalStateException& e) { - throw CMSException(e.what(), NULL); + throw cms::IllegalStateException(e.what()); } catch (cms::CMSException&) { diff --git a/activemq-cpp/src/main/activemq/commands/Message.cpp b/activemq-cpp/src/main/activemq/commands/Message.cpp index 22858a1b5..6e86df913 100644 --- a/activemq-cpp/src/main/activemq/commands/Message.cpp +++ b/activemq-cpp/src/main/activemq/commands/Message.cpp @@ -20,10 +20,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -1163,9 +1163,10 @@ void Message::beforeMarshal(wireformat::WireFormat* wireFormat AMQCPP_UNUSED) marshalledProperties); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -1225,7 +1226,5 @@ void Message::ensurePropertiesUnmarshaled() const << ", exception=" << e.getMessage()); throw; } - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() } } diff --git a/activemq-cpp/src/main/activemq/commands/WireFormatInfo.cpp b/activemq-cpp/src/main/activemq/commands/WireFormatInfo.cpp index 4e53caa72..5662a5347 100644 --- a/activemq-cpp/src/main/activemq/commands/WireFormatInfo.cpp +++ b/activemq-cpp/src/main/activemq/commands/WireFormatInfo.cpp @@ -18,8 +18,8 @@ #include #include -#include #include +#include #include #include @@ -360,9 +360,10 @@ void WireFormatInfo::beforeMarshal(WireFormat* wireFormat AMQCPP_UNUSED) marshalledProperties); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -373,9 +374,10 @@ void WireFormatInfo::afterUnmarshal(WireFormat* wireFormat AMQCPP_UNUSED) marshal::PrimitiveTypesMarshaller::unmarshal(&properties, marshalledProperties); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/main/activemq/exceptions/IoCatchMacros.h b/activemq-cpp/src/main/activemq/exceptions/IoCatchMacros.h index d9127779a..e2dbb4e1c 100644 --- a/activemq-cpp/src/main/activemq/exceptions/IoCatchMacros.h +++ b/activemq-cpp/src/main/activemq/exceptions/IoCatchMacros.h @@ -18,6 +18,14 @@ #ifndef _ACTIVEMQ_EXCEPTIONS_IOCATCHMACROS_H_ #define _ACTIVEMQ_EXCEPTIONS_IOCATCHMACROS_H_ +/* + * Implementation helpers AMQ_IOSTREAM_* (Decaf + AMQ stream exception ladder). + * OpenWire / DataStream marshalling uses the historical three-macro call shape + * via activemq/wireformat/openwire/marshal/OpenWireMarshalCatchMacros.h + * (AMQ_CATCH_RETHROW / AMQ_CATCH_EXCEPTION_CONVERT / AMQ_CATCHALL_THROW with + * explicit activemq::exceptions::IOException parameters for review). + */ + #include #include #include diff --git a/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h b/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h index 4990a6f83..099fdb6fe 100644 --- a/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h +++ b/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h @@ -431,6 +431,12 @@ namespace util ex.setMark(__FILE__, __LINE__); \ throw ex.convertToCMSException(); \ } \ + catch (decaf::lang::Exception & ex) \ + { \ + ex.setMark(__FILE__, __LINE__); \ + activemq::exceptions::ActiveMQException amqEx(ex); \ + throw amqEx.convertToCMSException(); \ + } \ catch (std::exception & ex) \ { \ decaf::lang::Exception cause(__FILE__, __LINE__, "%s", ex.what()); \ diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp index 01fd04a62..d881fcdf5 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp @@ -22,13 +22,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -283,10 +283,10 @@ void OpenWireFormat::marshal(const std::shared_ptr command, dataOut->writeByte(NULL_TYPE); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -329,10 +329,10 @@ std::shared_ptr OpenWireFormat::unmarshal( return command; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -417,10 +417,10 @@ commands::DataStructure* OpenWireFormat::doUnmarshal( return NULL; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -469,10 +469,10 @@ int OpenWireFormat::tightMarshalNestedObject1(commands::DataStructure* object, return 1 + dsm->tightMarshal1(this, object, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -514,10 +514,10 @@ void OpenWireFormat::tightMarshalNestedObject2(DataStructure* o, dsm->tightMarshal2(this, o, ds, bs); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -566,10 +566,10 @@ DataStructure* OpenWireFormat::tightUnmarshalNestedObject(DataInputStream* dis, return NULL; } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -603,10 +603,10 @@ DataStructure* OpenWireFormat::looseUnmarshalNestedObject( return NULL; } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -638,10 +638,10 @@ void OpenWireFormat::looseMarshalNestedObject( dsm->looseMarshal(this, o, dataOut); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -661,8 +661,8 @@ void OpenWireFormat::renegotiateWireFormat(const WireFormatInfo& info) preferedWireFormatInfo->isStackTraceEnabled(); this->tcpNoDelayEnabled = info.isTcpNoDelayEnabled() && preferedWireFormatInfo->isTcpNoDelayEnabled(); - this->cacheEnabled = info.isCacheEnabled() && - preferedWireFormatInfo->isCacheEnabled(); + this->cacheEnabled = info.isCacheEnabled() && + preferedWireFormatInfo->isCacheEnabled(); this->tightEncodingEnabled = info.isTightEncodingEnabled() && preferedWireFormatInfo->isTightEncodingEnabled(); diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.h index 28002773c..9dbc5b1be 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.h +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.h @@ -21,9 +21,9 @@ #include #include #include -#include #include #include +#include #include namespace activemq diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/OpenWireMarshalCatchMacros.h b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/OpenWireMarshalCatchMacros.h new file mode 100644 index 000000000..22d0655a9 --- /dev/null +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/OpenWireMarshalCatchMacros.h @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSHAL_OPENWIREMARSHALCATCHMACROS_H_ +#define _ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSHAL_OPENWIREMARSHALCATCHMACROS_H_ + +#include + +/** + * OpenWire / DataStream marshalling uses the same three trailing macros as the + * historical Apache OpenWire Java generator, with explicit type parameters for + * review. Parameters document intent; expansion is the shared Decaf+AMQ + * iostream ladder in IoCatchMacros.h (AMQ_IOSTREAM_*). + * + * Include this header from OpenWire marshal code paths instead of relying on + * the generic AMQ_CATCH_* macros from ExceptionDefines.h alone. + */ +#ifdef AMQ_CATCH_RETHROW +#undef AMQ_CATCH_RETHROW +#endif +#ifdef AMQ_CATCH_EXCEPTION_CONVERT +#undef AMQ_CATCH_EXCEPTION_CONVERT +#endif +#ifdef AMQ_CATCHALL_THROW +#undef AMQ_CATCHALL_THROW +#endif + +#define AMQ_CATCH_RETHROW(ioThrowable) AMQ_IOSTREAM_CATCH_RETHROW() + +/** + * First parameter names the primary non-IO failure (ActiveMQException or + * decaf::lang::Exception); second is always activemq::exceptions::IOException. + * Expansion handles both ActiveMQException and decaf::lang::Exception in a + * fixed order so either spelling in generated code stays correct. + */ +#define AMQ_CATCH_EXCEPTION_CONVERT(sourceThrowable, ioThrowable) \ + AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() \ + AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() + +#define AMQ_CATCHALL_THROW(ioThrowable) AMQ_IOSTREAM_CATCHALL_THROW() + +#endif /* _ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSHAL_OPENWIREMARSHALCATCHMACROS_H_ \ + */ diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.cpp index b787226cf..105b6118c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -80,9 +81,10 @@ void ActiveMQBlobMessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setDeletedByBroker(bs->readBoolean()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -115,9 +117,10 @@ int ActiveMQBlobMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -148,9 +151,10 @@ void ActiveMQBlobMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs->readBoolean(); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -179,9 +183,10 @@ void ActiveMQBlobMessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setDeletedByBroker(dataIn->readBoolean()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -210,7 +215,8 @@ void ActiveMQBlobMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeBoolean(info->isDeletedByBroker()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.cpp index e922e5996..ff692f265 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQBytesMessageMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -68,9 +69,10 @@ void ActiveMQBytesMessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -89,9 +91,10 @@ int ActiveMQBytesMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -108,9 +111,10 @@ void ActiveMQBytesMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -126,9 +130,10 @@ void ActiveMQBytesMessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -144,7 +149,8 @@ void ActiveMQBytesMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.cpp index 440c00914..32ba613be 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQDestinationMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -57,9 +58,10 @@ void ActiveMQDestinationMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->setPhysicalName(tightUnmarshalString(dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -79,9 +81,10 @@ int ActiveMQDestinationMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -101,9 +104,10 @@ void ActiveMQDestinationMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); tightMarshalString2(info->getPhysicalName(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -120,9 +124,10 @@ void ActiveMQDestinationMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->setPhysicalName(looseUnmarshalString(dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -139,7 +144,8 @@ void ActiveMQDestinationMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); looseMarshalString(info->getPhysicalName(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.cpp index e0d5a9815..d6e3e1309 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMapMessageMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -68,9 +69,10 @@ void ActiveMQMapMessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -89,9 +91,10 @@ int ActiveMQMapMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -108,9 +111,10 @@ void ActiveMQMapMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -126,9 +130,10 @@ void ActiveMQMapMessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -144,7 +149,8 @@ void ActiveMQMapMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.cpp index a097515bd..732a7ee33 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQMessageMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -67,9 +68,10 @@ void ActiveMQMessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -87,9 +89,10 @@ int ActiveMQMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -105,9 +108,10 @@ void ActiveMQMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, ActiveMQMessage* info = dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -122,9 +126,10 @@ void ActiveMQMessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -139,7 +144,8 @@ void ActiveMQMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.cpp index 4255cc5d5..4e290c49e 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQObjectMessageMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -69,9 +70,10 @@ void ActiveMQObjectMessageMarshaller::tightUnmarshal( info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -90,9 +92,10 @@ int ActiveMQObjectMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -109,9 +112,10 @@ void ActiveMQObjectMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -128,9 +132,10 @@ void ActiveMQObjectMessageMarshaller::looseUnmarshal( info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -146,7 +151,8 @@ void ActiveMQObjectMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.cpp index c6dcc0ca0..f51d034a6 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQQueueMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -65,9 +66,10 @@ void ActiveMQQueueMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -83,9 +85,10 @@ int ActiveMQQueueMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -101,9 +104,10 @@ void ActiveMQQueueMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -117,9 +121,10 @@ void ActiveMQQueueMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -133,7 +138,8 @@ void ActiveMQQueueMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.cpp index 92a031afb..9f0ec243e 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQStreamMessageMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -69,9 +70,10 @@ void ActiveMQStreamMessageMarshaller::tightUnmarshal( info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -90,9 +92,10 @@ int ActiveMQStreamMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -109,9 +112,10 @@ void ActiveMQStreamMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -128,9 +132,10 @@ void ActiveMQStreamMessageMarshaller::looseUnmarshal( info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -146,7 +151,8 @@ void ActiveMQStreamMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.cpp index 9bb4eeeae..8e729de56 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempDestinationMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -54,9 +55,10 @@ void ActiveMQTempDestinationMarshaller::tightUnmarshal( dataIn, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -73,9 +75,10 @@ int ActiveMQTempDestinationMarshaller::tightMarshal1( return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -92,9 +95,10 @@ void ActiveMQTempDestinationMarshaller::tightMarshal2( dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -109,9 +113,10 @@ void ActiveMQTempDestinationMarshaller::looseUnmarshal( dataStructure, dataIn); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -126,7 +131,8 @@ void ActiveMQTempDestinationMarshaller::looseMarshal( dataStructure, dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.cpp index 56b131b5b..dba903bb6 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempQueueMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -65,9 +66,10 @@ void ActiveMQTempQueueMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -83,9 +85,10 @@ int ActiveMQTempQueueMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -101,9 +104,10 @@ void ActiveMQTempQueueMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -117,9 +121,10 @@ void ActiveMQTempQueueMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -133,7 +138,8 @@ void ActiveMQTempQueueMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.cpp index 0015f428b..939415071 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTempTopicMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -65,9 +66,10 @@ void ActiveMQTempTopicMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -83,9 +85,10 @@ int ActiveMQTempTopicMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -101,9 +104,10 @@ void ActiveMQTempTopicMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -117,9 +121,10 @@ void ActiveMQTempTopicMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -133,7 +138,8 @@ void ActiveMQTempTopicMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.cpp index db2d00ebe..b34a8d75c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTextMessageMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -68,9 +69,10 @@ void ActiveMQTextMessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -89,9 +91,10 @@ int ActiveMQTextMessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -108,9 +111,10 @@ void ActiveMQTextMessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -126,9 +130,10 @@ void ActiveMQTextMessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->beforeUnmarshal(wireFormat); info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -144,7 +149,8 @@ void ActiveMQTextMessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.cpp index 29981fa0c..7ecda75df 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ActiveMQTopicMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -65,9 +66,10 @@ void ActiveMQTopicMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -83,9 +85,10 @@ int ActiveMQTopicMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -101,9 +104,10 @@ void ActiveMQTopicMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -117,9 +121,10 @@ void ActiveMQTopicMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -133,7 +138,8 @@ void ActiveMQTopicMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.cpp index bd9a365aa..ceaab028a 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BaseCommandMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -57,9 +58,10 @@ void BaseCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setCommandId(dataIn->readInt()); info->setResponseRequired(bs->readBoolean()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -78,9 +80,10 @@ int BaseCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -100,9 +103,10 @@ void BaseCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->writeInt(info->getCommandId()); bs->readBoolean(); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -119,9 +123,10 @@ void BaseCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setCommandId(dataIn->readInt()); info->setResponseRequired(dataIn->readBoolean()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -138,7 +143,8 @@ void BaseCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeInt(info->getCommandId()); dataOut->writeBoolean(info->isResponseRequired()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.cpp index c77b04512..e62aeb0e5 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerIdMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -68,9 +69,10 @@ void BrokerIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, BrokerId* info = dynamic_cast(dataStructure); info->setValue(tightUnmarshalString(dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -89,9 +91,10 @@ int BrokerIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -110,9 +113,10 @@ void BrokerIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, BrokerId* info = dynamic_cast(dataStructure); tightMarshalString2(info->getValue(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -128,9 +132,10 @@ void BrokerIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, BrokerId* info = dynamic_cast(dataStructure); info->setValue(looseUnmarshalString(dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -146,7 +151,8 @@ void BrokerIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); looseMarshalString(info->getValue(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.cpp index 9c39d1d0a..e826a4fd0 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/BrokerInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -113,9 +114,10 @@ void BrokerInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setNetworkProperties(tightUnmarshalString(dataIn, bs)); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -166,9 +168,10 @@ int BrokerInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -222,9 +225,10 @@ void BrokerInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalString2(info->getNetworkProperties(), dataOut, bs); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -285,9 +289,10 @@ void BrokerInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setNetworkProperties(looseUnmarshalString(dataIn)); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -334,7 +339,8 @@ void BrokerInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalString(info->getNetworkProperties(), dataOut); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.cpp index 60fb6ade9..dbd3fc17b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionControlMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -92,9 +93,10 @@ void ConnectionControlMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setToken(tightUnmarshalByteArray(dataIn, bs)); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -139,9 +141,10 @@ int ConnectionControlMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -191,9 +194,10 @@ void ConnectionControlMarshaller::tightMarshal2(OpenWireFormat* wireFormat, } } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -233,9 +237,10 @@ void ConnectionControlMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setToken(looseUnmarshalByteArray(dataIn)); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -281,7 +286,8 @@ void ConnectionControlMarshaller::looseMarshal(OpenWireFormat* wireFormat, } } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.cpp index 5a5b0b824..e960dd5a6 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionErrorMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -73,9 +74,10 @@ void ConnectionErrorMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -98,9 +100,10 @@ int ConnectionErrorMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -126,9 +129,10 @@ void ConnectionErrorMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -149,9 +153,10 @@ void ConnectionErrorMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalNestedObject(wireFormat, dataIn)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -170,7 +175,8 @@ void ConnectionErrorMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getConnectionId().get(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.cpp index 389410369..923a7815c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionIdMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -68,9 +69,10 @@ void ConnectionIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, ConnectionId* info = dynamic_cast(dataStructure); info->setValue(tightUnmarshalString(dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -89,9 +91,10 @@ int ConnectionIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -110,9 +113,10 @@ void ConnectionIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, ConnectionId* info = dynamic_cast(dataStructure); tightMarshalString2(info->getValue(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -128,9 +132,10 @@ void ConnectionIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, ConnectionId* info = dynamic_cast(dataStructure); info->setValue(looseUnmarshalString(dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -146,7 +151,8 @@ void ConnectionIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); looseMarshalString(info->getValue(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.cpp index cd5820858..d65b551c2 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConnectionInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -110,9 +111,10 @@ void ConnectionInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setClientIp(tightUnmarshalString(dataIn, bs)); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -157,9 +159,10 @@ int ConnectionInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -206,9 +209,10 @@ void ConnectionInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalString2(info->getClientIp(), dataOut, bs); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -266,9 +270,10 @@ void ConnectionInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setClientIp(looseUnmarshalString(dataIn)); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -309,7 +314,8 @@ void ConnectionInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalString(info->getClientIp(), dataOut); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.cpp index 08372483e..032ba3be2 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerControlMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -93,9 +94,10 @@ void ConsumerControlMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setStop(bs->readBoolean()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -137,9 +139,10 @@ int ConsumerControlMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -185,9 +188,10 @@ void ConsumerControlMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs->readBoolean(); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -228,9 +232,10 @@ void ConsumerControlMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setStop(dataIn->readBoolean()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -269,7 +274,8 @@ void ConsumerControlMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeBoolean(info->isStop()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.cpp index 945a3b354..cfb4c83f5 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerIdMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -70,9 +71,10 @@ void ConsumerIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setSessionId(tightUnmarshalLong(wireFormat, dataIn, bs)); info->setValue(tightUnmarshalLong(wireFormat, dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -93,9 +95,10 @@ int ConsumerIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -116,9 +119,10 @@ void ConsumerIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalLong2(wireFormat, info->getSessionId(), dataOut, bs); tightMarshalLong2(wireFormat, info->getValue(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -136,9 +140,10 @@ void ConsumerIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setSessionId(looseUnmarshalLong(wireFormat, dataIn)); info->setValue(looseUnmarshalLong(wireFormat, dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -156,7 +161,8 @@ void ConsumerIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalLong(wireFormat, info->getSessionId(), dataOut); looseMarshalLong(wireFormat, info->getValue(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.cpp index 4eb08cf98..08e03c73b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ConsumerInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -132,9 +133,10 @@ void ConsumerInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, } } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -184,9 +186,10 @@ int ConsumerInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 9; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -244,9 +247,10 @@ void ConsumerInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -324,9 +328,10 @@ void ConsumerInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, } } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -375,7 +380,8 @@ void ConsumerInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.cpp index d0743165b..252e363d6 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ControlCommandMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -68,9 +69,10 @@ void ControlCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, ControlCommand* info = dynamic_cast(dataStructure); info->setCommand(tightUnmarshalString(dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -88,9 +90,10 @@ int ControlCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -109,9 +112,10 @@ void ControlCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, ControlCommand* info = dynamic_cast(dataStructure); tightMarshalString2(info->getCommand(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -127,9 +131,10 @@ void ControlCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, ControlCommand* info = dynamic_cast(dataStructure); info->setCommand(looseUnmarshalString(dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -143,7 +148,8 @@ void ControlCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, BaseCommandMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); looseMarshalString(info->getCommand(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.cpp index 2f14a5420..14616bb4c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataArrayResponseMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -84,9 +85,10 @@ void DataArrayResponseMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->getData().clear(); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -105,9 +107,10 @@ int DataArrayResponseMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -127,9 +130,10 @@ void DataArrayResponseMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dynamic_cast(dataStructure); tightMarshalObjectArray2(wireFormat, info->getData(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -159,9 +163,10 @@ void DataArrayResponseMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->getData().clear(); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -176,7 +181,8 @@ void DataArrayResponseMarshaller::looseMarshal(OpenWireFormat* wireFormat, ResponseMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); looseMarshalObjectArray(wireFormat, info->getData(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.cpp index 716fac82d..5808cc204 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DataResponseMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -70,9 +71,10 @@ void DataResponseMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -90,9 +92,10 @@ int DataResponseMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -114,9 +117,10 @@ void DataResponseMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -132,9 +136,10 @@ void DataResponseMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalNestedObject(wireFormat, dataIn)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -148,7 +153,8 @@ void DataResponseMarshaller::looseMarshal(OpenWireFormat* wireFormat, ResponseMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); looseMarshalNestedObject(wireFormat, info->getData().get(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.cpp index 5985b8f97..26dde6b12 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DestinationInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -91,9 +92,10 @@ void DestinationInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->getBrokerPath().clear(); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -118,9 +120,10 @@ int DestinationInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 1; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -149,9 +152,10 @@ void DestinationInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalLong2(wireFormat, info->getTimeout(), dataOut, bs); tightMarshalObjectArray2(wireFormat, info->getBrokerPath(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -190,9 +194,10 @@ void DestinationInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->getBrokerPath().clear(); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -214,7 +219,8 @@ void DestinationInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalLong(wireFormat, info->getTimeout(), dataOut); looseMarshalObjectArray(wireFormat, info->getBrokerPath(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.cpp index 05a5730f4..a3b6bb3bb 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/DiscoveryEventMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -69,9 +70,10 @@ void DiscoveryEventMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setServiceName(tightUnmarshalString(dataIn, bs)); info->setBrokerName(tightUnmarshalString(dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -91,9 +93,10 @@ int DiscoveryEventMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -113,9 +116,10 @@ void DiscoveryEventMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalString2(info->getServiceName(), dataOut, bs); tightMarshalString2(info->getBrokerName(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -132,9 +136,10 @@ void DiscoveryEventMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setServiceName(looseUnmarshalString(dataIn)); info->setBrokerName(looseUnmarshalString(dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -151,7 +156,8 @@ void DiscoveryEventMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalString(info->getServiceName(), dataOut); looseMarshalString(info->getBrokerName(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.cpp index ad3fcfd88..48444f14b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ExceptionResponseMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -71,9 +72,10 @@ void ExceptionResponseMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalBrokerError(wireFormat, dataIn, bs)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -94,9 +96,10 @@ int ExceptionResponseMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -119,9 +122,10 @@ void ExceptionResponseMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -138,9 +142,10 @@ void ExceptionResponseMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalBrokerError(wireFormat, dataIn)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -157,7 +162,8 @@ void ExceptionResponseMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getException().get(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.cpp index 25c380525..6a8cb4c6f 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/FlushCommandMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -65,9 +66,10 @@ void FlushCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -82,9 +84,10 @@ int FlushCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -100,9 +103,10 @@ void FlushCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -116,9 +120,10 @@ void FlushCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -130,7 +135,8 @@ void FlushCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, { BaseCommandMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.cpp index ff3697b81..c2777a03b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/IntegerResponseMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -68,9 +69,10 @@ void IntegerResponseMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, IntegerResponse* info = dynamic_cast(dataStructure); info->setResult(dataIn->readInt()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -85,9 +87,10 @@ int IntegerResponseMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -106,9 +109,10 @@ void IntegerResponseMarshaller::tightMarshal2(OpenWireFormat* wireFormat, IntegerResponse* info = dynamic_cast(dataStructure); dataOut->writeInt(info->getResult()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -122,9 +126,10 @@ void IntegerResponseMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, IntegerResponse* info = dynamic_cast(dataStructure); info->setResult(dataIn->readInt()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -138,7 +143,8 @@ void IntegerResponseMarshaller::looseMarshal(OpenWireFormat* wireFormat, ResponseMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); dataOut->writeInt(info->getResult()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.cpp index ca9ea2c44..76fb6cd75 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalQueueAckMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -73,9 +74,10 @@ void JournalQueueAckMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -99,9 +101,10 @@ int JournalQueueAckMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -127,9 +130,10 @@ void JournalQueueAckMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -150,9 +154,10 @@ void JournalQueueAckMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalNestedObject(wireFormat, dataIn)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -173,7 +178,8 @@ void JournalQueueAckMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getMessageAck().get(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.cpp index a3a3a1178..0df3009d9 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTopicAckMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -78,9 +79,10 @@ void JournalTopicAckMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -110,9 +112,10 @@ int JournalTopicAckMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -145,9 +148,10 @@ void JournalTopicAckMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -173,9 +177,10 @@ void JournalTopicAckMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalNestedObject(wireFormat, dataIn)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -202,7 +207,8 @@ void JournalTopicAckMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getTransactionId().get(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.cpp index 3828c6596..39ec1c36d 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTraceMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -68,9 +69,10 @@ void JournalTraceMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, JournalTrace* info = dynamic_cast(dataStructure); info->setMessage(tightUnmarshalString(dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -89,9 +91,10 @@ int JournalTraceMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -110,9 +113,10 @@ void JournalTraceMarshaller::tightMarshal2(OpenWireFormat* wireFormat, JournalTrace* info = dynamic_cast(dataStructure); tightMarshalString2(info->getMessage(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -128,9 +132,10 @@ void JournalTraceMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, JournalTrace* info = dynamic_cast(dataStructure); info->setMessage(looseUnmarshalString(dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -146,7 +151,8 @@ void JournalTraceMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); looseMarshalString(info->getMessage(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.cpp index 60e319348..d29310607 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/JournalTransactionMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -73,9 +74,10 @@ void JournalTransactionMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setType(dataIn->readByte()); info->setWasPrepared(bs->readBoolean()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -98,9 +100,10 @@ int JournalTransactionMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 1; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -125,9 +128,10 @@ void JournalTransactionMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->write(info->getType()); bs->readBoolean(); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -148,9 +152,10 @@ void JournalTransactionMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setType(dataIn->readByte()); info->setWasPrepared(dataIn->readBoolean()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -171,7 +176,8 @@ void JournalTransactionMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->write(info->getType()); dataOut->writeBoolean(info->getWasPrepared()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.cpp index e466fd10a..30a901e72 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/KeepAliveInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -65,9 +66,10 @@ void KeepAliveInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -82,9 +84,10 @@ int KeepAliveInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -100,9 +103,10 @@ void KeepAliveInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -116,9 +120,10 @@ void KeepAliveInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -130,7 +135,8 @@ void KeepAliveInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, { BaseCommandMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.cpp index e19ccdb06..71499c30a 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LastPartialCommandMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -65,9 +66,10 @@ void LastPartialCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -83,9 +85,10 @@ int LastPartialCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -101,9 +104,10 @@ void LastPartialCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -117,9 +121,10 @@ void LastPartialCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -133,7 +138,8 @@ void LastPartialCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.cpp index e239384f0..499c741d3 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/LocalTransactionIdMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -72,9 +73,10 @@ void LocalTransactionIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( tightUnmarshalCachedObject(wireFormat, dataIn, bs)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -97,9 +99,10 @@ int LocalTransactionIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -123,9 +126,10 @@ void LocalTransactionIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -145,9 +149,10 @@ void LocalTransactionIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, std::shared_ptr(dynamic_cast( looseUnmarshalCachedObject(wireFormat, dataIn)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -167,7 +172,8 @@ void LocalTransactionIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getConnectionId().get(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.cpp index 4da2e5ad3..38f406846 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageAckMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -93,9 +94,10 @@ void MessageAckMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, tightUnmarshalBrokerError(wireFormat, dataIn, bs)))); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -136,9 +138,10 @@ int MessageAckMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 5; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -188,9 +191,10 @@ void MessageAckMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -231,9 +235,10 @@ void MessageAckMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, looseUnmarshalBrokerError(wireFormat, dataIn)))); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -272,7 +277,8 @@ void MessageAckMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.cpp index 74a4229da..3e9257361 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -79,9 +80,10 @@ void MessageDispatchMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); info->setRedeliveryCounter(dataIn->readInt()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -106,9 +108,10 @@ int MessageDispatchMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -139,9 +142,10 @@ void MessageDispatchMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); dataOut->writeInt(info->getRedeliveryCounter()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -165,9 +169,10 @@ void MessageDispatchMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, looseUnmarshalNestedObject(wireFormat, dataIn)))); info->setRedeliveryCounter(dataIn->readInt()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -188,7 +193,8 @@ void MessageDispatchMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalNestedObject(wireFormat, info->getMessage().get(), dataOut); dataOut->writeInt(info->getRedeliveryCounter()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.cpp index 65b835d9c..754a156fb 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -78,9 +79,10 @@ void MessageDispatchNotificationMarshaller::tightUnmarshal( info->setMessageId(std::shared_ptr(dynamic_cast( tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -109,9 +111,10 @@ int MessageDispatchNotificationMarshaller::tightMarshal1( return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -147,9 +150,10 @@ void MessageDispatchNotificationMarshaller::tightMarshal2( dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -175,9 +179,10 @@ void MessageDispatchNotificationMarshaller::looseUnmarshal( info->setMessageId(std::shared_ptr(dynamic_cast( looseUnmarshalNestedObject(wireFormat, dataIn)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -202,7 +207,8 @@ void MessageDispatchNotificationMarshaller::looseMarshal( info->getMessageId().get(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.cpp index b9a7c9556..2bb1a8b2b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageIdMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -79,9 +80,10 @@ void MessageIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setProducerSequenceId(tightUnmarshalLong(wireFormat, dataIn, bs)); info->setBrokerSequenceId(tightUnmarshalLong(wireFormat, dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -111,9 +113,10 @@ int MessageIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -147,9 +150,10 @@ void MessageIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); tightMarshalLong2(wireFormat, info->getBrokerSequenceId(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -176,9 +180,10 @@ void MessageIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setProducerSequenceId(looseUnmarshalLong(wireFormat, dataIn)); info->setBrokerSequenceId(looseUnmarshalLong(wireFormat, dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -205,7 +210,8 @@ void MessageIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalLong(wireFormat, info->getProducerSequenceId(), dataOut); looseMarshalLong(wireFormat, info->getBrokerSequenceId(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.cpp index a94aad4cc..fc658c7c9 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -152,9 +153,10 @@ void MessageMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setJMSXGroupFirstForConsumer(bs->readBoolean()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -239,9 +241,10 @@ int MessageMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 9; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -352,9 +355,10 @@ void MessageMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs->readBoolean(); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -463,9 +467,10 @@ void MessageMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setJMSXGroupFirstForConsumer(dataIn->readBoolean()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -559,7 +564,8 @@ void MessageMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeBoolean(info->isJMSXGroupFirstForConsumer()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.cpp index 831234392..8de574029 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessagePullMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -87,9 +88,10 @@ void MessagePullMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, tightUnmarshalNestedObject(wireFormat, dataIn, bs)))); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -126,9 +128,10 @@ int MessagePullMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -169,9 +172,10 @@ void MessagePullMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -206,9 +210,10 @@ void MessagePullMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, looseUnmarshalNestedObject(wireFormat, dataIn)))); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -241,7 +246,8 @@ void MessagePullMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.cpp index ad83ea953..23cec53e6 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/NetworkBridgeFilterMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -82,9 +83,10 @@ void NetworkBridgeFilterMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setConsumerTTL(dataIn->readInt()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -115,9 +117,10 @@ int NetworkBridgeFilterMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 8; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -151,9 +154,10 @@ void NetworkBridgeFilterMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->writeInt(info->getConsumerTTL()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -183,9 +187,10 @@ void NetworkBridgeFilterMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setConsumerTTL(dataIn->readInt()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -215,7 +220,8 @@ void NetworkBridgeFilterMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeInt(info->getConsumerTTL()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.cpp index d802bc5ce..339d4952c 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/PartialCommandMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -69,9 +70,10 @@ void PartialCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setCommandId(dataIn->readInt()); info->setData(tightUnmarshalByteArray(dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -91,9 +93,10 @@ int PartialCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -120,9 +123,10 @@ void PartialCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, (int)info->getData().size()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -139,9 +143,10 @@ void PartialCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setCommandId(dataIn->readInt()); info->setData(looseUnmarshalByteArray(dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -166,7 +171,8 @@ void PartialCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, (int)info->getData().size()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.cpp index dafcd181f..a363d0bd1 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerAckMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -80,9 +81,10 @@ void ProducerAckMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setSize(dataIn->readInt()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -111,9 +113,10 @@ int ProducerAckMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -145,9 +148,10 @@ void ProducerAckMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->writeInt(info->getSize()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -175,9 +179,10 @@ void ProducerAckMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setSize(dataIn->readInt()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -203,7 +208,8 @@ void ProducerAckMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeInt(info->getSize()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.cpp index 5a2bbe0f4..c93255131 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerIdMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -70,9 +71,10 @@ void ProducerIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setValue(tightUnmarshalLong(wireFormat, dataIn, bs)); info->setSessionId(tightUnmarshalLong(wireFormat, dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -93,9 +95,10 @@ int ProducerIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -116,9 +119,10 @@ void ProducerIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalLong2(wireFormat, info->getValue(), dataOut, bs); tightMarshalLong2(wireFormat, info->getSessionId(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -136,9 +140,10 @@ void ProducerIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setValue(looseUnmarshalLong(wireFormat, dataIn)); info->setSessionId(looseUnmarshalLong(wireFormat, dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -156,7 +161,8 @@ void ProducerIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalLong(wireFormat, info->getValue(), dataOut); looseMarshalLong(wireFormat, info->getSessionId(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.cpp index 4dc05f43e..7ec0205e5 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ProducerInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -100,9 +101,10 @@ void ProducerInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setWindowSize(dataIn->readInt()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -136,9 +138,10 @@ int ProducerInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -176,9 +179,10 @@ void ProducerInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->writeInt(info->getWindowSize()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -226,9 +230,10 @@ void ProducerInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setWindowSize(dataIn->readInt()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -259,7 +264,8 @@ void ProducerInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeInt(info->getWindowSize()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.cpp index f098bbfd6..7933e5520 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -78,9 +79,10 @@ void RemoveInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, tightUnmarshalLong(wireFormat, dataIn, bs)); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -109,9 +111,10 @@ int RemoveInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -143,9 +146,10 @@ void RemoveInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -171,9 +175,10 @@ void RemoveInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, looseUnmarshalLong(wireFormat, dataIn)); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -198,7 +203,8 @@ void RemoveInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.cpp index 8eb06e764..0fa4af995 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/RemoveSubscriptionInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -74,9 +75,10 @@ void RemoveSubscriptionInfoMarshaller::tightUnmarshal( info->setSubcriptionName(tightUnmarshalString(dataIn, bs)); info->setClientId(tightUnmarshalString(dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -99,9 +101,10 @@ int RemoveSubscriptionInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -127,9 +130,10 @@ void RemoveSubscriptionInfoMarshaller::tightMarshal2( tightMarshalString2(info->getSubcriptionName(), dataOut, bs); tightMarshalString2(info->getClientId(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -151,9 +155,10 @@ void RemoveSubscriptionInfoMarshaller::looseUnmarshal( info->setSubcriptionName(looseUnmarshalString(dataIn)); info->setClientId(looseUnmarshalString(dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -172,7 +177,8 @@ void RemoveSubscriptionInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalString(info->getSubcriptionName(), dataOut); looseMarshalString(info->getClientId(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.cpp index da2d653bc..74fcd2d12 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ReplayCommandMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -69,9 +70,10 @@ void ReplayCommandMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setFirstNakNumber(dataIn->readInt()); info->setLastNakNumber(dataIn->readInt()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -86,9 +88,10 @@ int ReplayCommandMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 8; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -108,9 +111,10 @@ void ReplayCommandMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut->writeInt(info->getFirstNakNumber()); dataOut->writeInt(info->getLastNakNumber()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -127,9 +131,10 @@ void ReplayCommandMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setFirstNakNumber(dataIn->readInt()); info->setLastNakNumber(dataIn->readInt()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -144,7 +149,8 @@ void ReplayCommandMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeInt(info->getFirstNakNumber()); dataOut->writeInt(info->getLastNakNumber()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.cpp index d98a8f6b6..d7848f77a 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ResponseMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -68,9 +69,10 @@ void ResponseMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, Response* info = dynamic_cast(dataStructure); info->setCorrelationId(dataIn->readInt()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -85,9 +87,10 @@ int ResponseMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -106,9 +109,10 @@ void ResponseMarshaller::tightMarshal2(OpenWireFormat* wireFormat, Response* info = dynamic_cast(dataStructure); dataOut->writeInt(info->getCorrelationId()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -124,9 +128,10 @@ void ResponseMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, Response* info = dynamic_cast(dataStructure); info->setCorrelationId(dataIn->readInt()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -140,7 +145,8 @@ void ResponseMarshaller::looseMarshal(OpenWireFormat* wireFormat, BaseCommandMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); dataOut->writeInt(info->getCorrelationId()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.cpp index 574c53062..5a61160a3 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionIdMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -69,9 +70,10 @@ void SessionIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setConnectionId(tightUnmarshalString(dataIn, bs)); info->setValue(tightUnmarshalLong(wireFormat, dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -91,9 +93,10 @@ int SessionIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -113,9 +116,10 @@ void SessionIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, tightMarshalString2(info->getConnectionId(), dataOut, bs); tightMarshalLong2(wireFormat, info->getValue(), dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -132,9 +136,10 @@ void SessionIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setConnectionId(looseUnmarshalString(dataIn)); info->setValue(looseUnmarshalLong(wireFormat, dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -151,7 +156,8 @@ void SessionIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, looseMarshalString(info->getConnectionId(), dataOut); looseMarshalLong(wireFormat, info->getValue(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.cpp index 6bb1fcc12..d939162df 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SessionInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -69,9 +70,10 @@ void SessionInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setSessionId(std::shared_ptr(dynamic_cast( tightUnmarshalCachedObject(wireFormat, dataIn, bs)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -91,9 +93,10 @@ int SessionInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -115,9 +118,10 @@ void SessionInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -134,9 +138,10 @@ void SessionInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setSessionId(std::shared_ptr(dynamic_cast( looseUnmarshalCachedObject(wireFormat, dataIn)))); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -152,7 +157,8 @@ void SessionInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, info->getSessionId().get(), dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.cpp index 560aa0ad8..6c3ae1832 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/ShutdownInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -65,9 +66,10 @@ void ShutdownInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -82,9 +84,10 @@ int ShutdownInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -100,9 +103,10 @@ void ShutdownInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -116,9 +120,10 @@ void ShutdownInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -130,7 +135,8 @@ void ShutdownInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, { BaseCommandMarshaller::looseMarshal(wireFormat, dataStructure, dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.cpp index 62c5cd8b2..f6f10df5b 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/SubscriptionInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -86,9 +87,10 @@ void SubscriptionInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setNoLocal(bs->readBoolean()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -126,9 +128,10 @@ int SubscriptionInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -167,9 +170,10 @@ void SubscriptionInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs->readBoolean(); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -203,9 +207,10 @@ void SubscriptionInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setNoLocal(dataIn->readBoolean()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -239,7 +244,8 @@ void SubscriptionInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut->writeBoolean(info->isNoLocal()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.cpp index e0034ac83..bd70b3871 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionIdMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -53,9 +54,10 @@ void TransactionIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, dataIn, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -71,9 +73,10 @@ int TransactionIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 0; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -89,9 +92,10 @@ void TransactionIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, dataOut, bs); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -105,9 +109,10 @@ void TransactionIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, dataStructure, dataIn); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -121,7 +126,8 @@ void TransactionIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataStructure, dataOut); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.cpp index d6a2f965b..c9227a8de 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/TransactionInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -74,9 +75,10 @@ void TransactionInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, tightUnmarshalCachedObject(wireFormat, dataIn, bs)))); info->setType(dataIn->readByte()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -99,9 +101,10 @@ int TransactionInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 1; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -128,9 +131,10 @@ void TransactionInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, bs); dataOut->write(info->getType()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -152,9 +156,10 @@ void TransactionInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, looseUnmarshalCachedObject(wireFormat, dataIn)))); info->setType(dataIn->readByte()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -174,7 +179,8 @@ void TransactionInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, dataOut); dataOut->write(info->getType()); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.cpp index 8f71d9777..12413d8b7 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/WireFormatInfoMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -74,9 +75,10 @@ void WireFormatInfoMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -99,9 +101,10 @@ int WireFormatInfoMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 12; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -131,9 +134,10 @@ void WireFormatInfoMarshaller::tightMarshal2(OpenWireFormat* wireFormat, } info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -153,9 +157,10 @@ void WireFormatInfoMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setMarshalledProperties(looseUnmarshalByteArray(dataIn)); info->afterUnmarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -184,7 +189,8 @@ void WireFormatInfoMarshaller::looseMarshal(OpenWireFormat* wireFormat, } info->afterMarshal(wireFormat); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.cpp index d7db7e946..6b86836ef 100644 --- a/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/XATransactionIdMarshaller.cpp @@ -19,6 +19,7 @@ #include #include +#include #include // @@ -70,9 +71,10 @@ void XATransactionIdMarshaller::tightUnmarshal(OpenWireFormat* wireFormat, info->setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs)); info->setBranchQualifier(tightUnmarshalByteArray(dataIn, bs)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -98,9 +100,10 @@ int XATransactionIdMarshaller::tightMarshal1(OpenWireFormat* wireFormat, return rc + 4; } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -137,9 +140,10 @@ void XATransactionIdMarshaller::tightMarshal2(OpenWireFormat* wireFormat, (int)info->getBranchQualifier().size()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -157,9 +161,10 @@ void XATransactionIdMarshaller::looseUnmarshal(OpenWireFormat* wireFormat, info->setGlobalTransactionId(looseUnmarshalByteArray(dataIn)); info->setBranchQualifier(looseUnmarshalByteArray(dataIn)); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } /////////////////////////////////////////////////////////////////////////////// @@ -195,7 +200,8 @@ void XATransactionIdMarshaller::looseMarshal(OpenWireFormat* wireFormat, (int)info->getBranchQualifier().size()); } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_ACTIVEMQ_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(activemq::exceptions::ActiveMQException, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp b/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp index d86b08dc1..cb7d328cd 100644 --- a/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp @@ -25,8 +25,8 @@ #include #include -#include #include +#include #include using namespace std; @@ -159,9 +159,10 @@ void StompFrame::fromStream(decaf::io::DataInputStream* in) // Read the body. readBody(in); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -197,9 +198,10 @@ void StompFrame::readCommandHeader(decaf::io::DataInputStream* in) } } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -259,9 +261,10 @@ void StompFrame::readHeaders(decaf::io::DataInputStream* in) } } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -300,9 +303,10 @@ std::size_t StompFrame::readHeaderLine(std::vector& buffer, "StompWireFormat::readStompHeaderLine: " "Unrecoverable, error condition"); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -371,7 +375,8 @@ void StompFrame::readBody(decaf::io::DataInputStream* in) } } } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } diff --git a/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp b/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp index d855bf06d..998c789fd 100644 --- a/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp +++ b/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp @@ -42,8 +42,8 @@ #include #include -#include #include +#include #include #include #include @@ -199,9 +199,10 @@ void StompWireFormat::marshal(const std::shared_ptr command, // Let the Frame write itself to the output stream frame->toStream(out); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -282,9 +283,10 @@ std::shared_ptr StompWireFormat::unmarshal( __LINE__, "StompWireFormat::marshal - No Command Created from frame"); } - AMQ_IOSTREAM_CATCH_RETHROW() - AMQ_IOSTREAM_CATCH_CONVERT_LANG_EXCEPTION() - AMQ_IOSTREAM_CATCHALL_THROW() + AMQ_CATCH_RETHROW(activemq::exceptions::IOException) + AMQ_CATCH_EXCEPTION_CONVERT(decaf::lang::Exception, + activemq::exceptions::IOException) + AMQ_CATCHALL_THROW(activemq::exceptions::IOException) } //////////////////////////////////////////////////////////////////////////////// diff --git a/activemq-cpp/src/test/activemq/util/AdvisorySupportTest.cpp b/activemq-cpp/src/test/activemq/util/AdvisorySupportTest.cpp index 3c26ef737..a65465828 100644 --- a/activemq-cpp/src/test/activemq/util/AdvisorySupportTest.cpp +++ b/activemq-cpp/src/test/activemq/util/AdvisorySupportTest.cpp @@ -1,4 +1,4 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership.