Skip to content

Commit e459771

Browse files
committed
Deleted wrongly pasted javadocs and fixed a minor bug
1 parent 88a0744 commit e459771

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/util/Mimetype.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ public static Mimetype getInstance() {
116116
* to find the corresponding mime type. If the file has no extension, or the extension is not
117117
* available in the listing contained in this class, the default mimetype
118118
* <code>application/octet-stream</code> is returned.
119-
* <p>
120-
* A file extension is one or more characters that occur after the last period (.) in the file's name.
121-
* If a file has no extension,
122-
* Guesses the mimetype of file data based on the file's extension.
123119
*
124120
* @param path the file whose extension may match a known mimetype.
125121
* @return the file's mimetype based on its extension, or a default value of
@@ -132,18 +128,14 @@ public String getMimetype(Path path) {
132128
if (file != null) {
133129
return getMimetype(file.toString());
134130
}
135-
return null;
131+
return MIMETYPE_OCTET_STREAM;
136132
}
137133

138134
/**
139135
* Determines the mimetype of a file by looking up the file's extension in an internal listing
140136
* to find the corresponding mime type. If the file has no extension, or the extension is not
141137
* available in the listing contained in this class, the default mimetype
142138
* <code>application/octet-stream</code> is returned.
143-
* <p>
144-
* A file extension is one or more characters that occur after the last period (.) in the file's name.
145-
* If a file has no extension,
146-
* Guesses the mimetype of file data based on the file's extension.
147139
*
148140
* @param file the file whose extension may match a known mimetype.
149141
* @return the file's mimetype based on its extension, or a default value of
@@ -159,10 +151,6 @@ public String getMimetype(File file) {
159151
* no extension, or the extension is not available in the listing contained
160152
* in this class, the default mimetype <code>application/octet-stream</code>
161153
* is returned.
162-
* <p>
163-
* A file extension is one or more characters that occur after the last
164-
* period (.) in the file's name. If a file has no extension, Guesses the
165-
* mimetype of file data based on the file's extension.
166154
*
167155
* @param fileName The name of the file whose extension may match a known
168156
* mimetype.

core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/util/MimetypeTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
package software.amazon.awssdk.core.internal.util;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.mockito.Mockito.mock;
20+
import static org.mockito.Mockito.when;
1921

22+
import java.nio.file.Path;
2023
import org.junit.BeforeClass;
2124
import org.junit.Test;
2225

@@ -48,4 +51,11 @@ public void unknownExtensions_defaulttoBeStream() throws Exception {
4851
public void noExtensions_defaulttoBeStream() throws Exception {
4952
assertThat(mimetype.getMimetype("test")).isEqualTo(Mimetype.MIMETYPE_OCTET_STREAM);
5053
}
54+
55+
@Test
56+
public void pathWithoutFileName_defaulttoBeStream() throws Exception {
57+
Path mockPath = mock(Path.class);
58+
when(mockPath.getFileName()).thenReturn(null);
59+
assertThat(mimetype.getMimetype(mockPath)).isEqualTo(Mimetype.MIMETYPE_OCTET_STREAM);
60+
}
5161
}

0 commit comments

Comments
 (0)