You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2018/10/23 12:40:49 UTC

[GitHub] pnowojski commented on a change in pull request #6705: [FLINK-10356][network] add sanity checks to SpillingAdaptiveSpanningRecordDeserializer

pnowojski commented on a change in pull request #6705: [FLINK-10356][network] add sanity checks to SpillingAdaptiveSpanningRecordDeserializer
URL: https://github.com/apache/flink/pull/6705#discussion_r227332295
 
 

 ##########
 File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/api/serialization/SpillingAdaptiveSpanningRecordDeserializer.java
 ##########
 @@ -549,21 +578,67 @@ private void addNextChunkFromMemorySegment(MemorySegment segment, int offset, in
 				}
 				else {
 					spillingChannel.close();
+					spillingChannel = null;
 
-					BufferedInputStream inStream = new BufferedInputStream(new FileInputStream(spillFile), 2 * 1024 * 1024);
+					BufferedInputStream inStream =
+						new BufferedInputStream(
+							new FileInputStream(checkNotNull(spillFile)),
+							2 * 1024 * 1024);
 					this.spillFileReader = new DataInputViewStreamWrapper(inStream);
 				}
 			}
 		}
 
-		private void moveRemainderToNonSpanningDeserializer(NonSpanningWrapper deserializer) {
+		private void moveRemainderToNonSpanningDeserializer(NonSpanningWrapper deserializer) throws IOException {
+			checkForDeserializationError(null);
+
 			deserializer.clear();
 
 			if (leftOverData != null) {
 				deserializer.initializeFromMemorySegment(leftOverData, leftOverStart, leftOverLimit);
 			}
 		}
 
+		/**
+		 * In addition to a potentially thrown {@link EOFException}, checks for further
+		 * deserialization errors and tries to throw an exception with a more meaningful error
+		 * message.
+		 *
+		 * @param eofException
+		 * 		exception thrown before the check (or <tt>null</tt> if there was none)
+		 *
+		 * @throws IOException
+		 * 		in case of too few or too many bytes read, an exception with more useful data for
+		 * 		debugging
+		 */
+		private void checkForDeserializationError(@Nullable EOFException eofException) throws IOException {
 
 Review comment:
   Don't use `@Nullable`: overload or change to `Optional`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services