You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by GitBox <gi...@apache.org> on 2021/01/27 05:27:23 UTC

[GitHub] [thrift] taras-protsiv commented on a change in pull request #2185: THRIFT-5237 Implement MAX_MESSAGE_SIZE and consolidate limits into a TConfiguration class (cpp)

taras-protsiv commented on a change in pull request #2185:
URL: https://github.com/apache/thrift/pull/2185#discussion_r565037317



##########
File path: lib/cpp/src/thrift/transport/TTransport.h
##########
@@ -238,11 +248,87 @@ class TTransport {
    */
   virtual const std::string getOrigin() const { return "Unknown"; }
 
+  std::shared_ptr<TConfiguration> getConfiguration() { return configuration_; }
+
+  void setConfiguration(std::shared_ptr<TConfiguration> config) { 
+    if (config != nullptr) configuration_ = config; 
+  }
+
+  /**
+   * Updates RemainingMessageSize to reflect then known real message size (e.g. framed transport).
+   * Will throw if we already consumed too many bytes or if the new size is larger than allowed.
+   *
+   * @param size  real message size
+   */
+  void updateKnownMessageSize(long int size)
+  {
+    long int consumed = knownMessageSize_ - remainingMessageSize_;
+    resetConsumedMessageSize(size);
+    countConsumedMessageBytes(consumed);
+  }
+
+  /**
+   * Throws if there are not enough bytes in the input stream to satisfy a read of numBytes bytes of data
+   *
+   * @param numBytes  numBytes bytes of data
+   */
+  void checkReadBytesAvailable(long int numBytes)
+  {
+    if (remainingMessageSize_ < numBytes)
+      throw new TTransportException(TTransportException::END_OF_FILE, "MaxMessageSize reached");

Review comment:
       throw raw pointer. 
   It will not be caught by try {...} catch ( const TTransportException& ).
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org