New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BEAM-59] Switch mimeType from mutable protected field to constructor #2793
Conversation
Protected mutable fields are a terrible design pattern
R: @lukecwik maybe you'll have thoughts on this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Please add comments about mime types and then merge.
@@ -1026,11 +1024,15 @@ public void verifyDeterministic() throws NonDeterministicException { | |||
WritableByteChannel create(WritableByteChannel channel) throws IOException; | |||
|
|||
/** | |||
* @return the MIME type that should be used for the files that will hold the output data | |||
* Returns the MIME type that should be used for the files that will hold the output data. May | |||
* return {@code null} if this {@code WritableByteChannelFactory} does not meaningful change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meaningful -> meaningfully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
*/ | ||
protected String mimeType = MimeTypes.TEXT; | ||
private final String mimeType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep a comment that this is the mimetype of the sink and that it can be overridden by the WritableByteChannelFactory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
*/ | ||
protected String mimeType = MimeTypes.TEXT; | ||
private final String mimeType; | ||
|
||
/** | ||
* Construct a new FileBasedWriter with a base filename. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment about the resolution order of mime types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! All done, will self-merge once green.
*/ | ||
protected String mimeType = MimeTypes.TEXT; | ||
private final String mimeType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
*/ | ||
protected String mimeType = MimeTypes.TEXT; | ||
private final String mimeType; | ||
|
||
/** | ||
* Construct a new FileBasedWriter with a base filename. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -1026,11 +1024,15 @@ public void verifyDeterministic() throws NonDeterministicException { | |||
WritableByteChannel create(WritableByteChannel channel) throws IOException; | |||
|
|||
/** | |||
* @return the MIME type that should be used for the files that will hold the output data | |||
* Returns the MIME type that should be used for the files that will hold the output data. May | |||
* return {@code null} if this {@code WritableByteChannelFactory} does not meaningful change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Protected mutable fields are a terrible design pattern, and this
information is known at construction time.
Also fix a minor bug in which the Binary MIME type of a FileBasedSink could erroneously be changed back to a Text MIME type when using an uncompressed channel.