Skip to content

Commit 2561795

Browse files
committed
refactor(ImageFileValidator): rename a local variable.
1 parent 76b203e commit 2561795

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/main/java/ru/mystamps/web/support/beanvalidation/ImageFileValidator.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,18 @@ public boolean isValid(MultipartFile file, ConstraintValidatorContext ctx) {
109109

110110
try (InputStream stream = file.getInputStream()) {
111111

112-
byte[] firstBytes = readEightBytes(stream);
113-
if (firstBytes == null) {
112+
byte[] bytes = readEightBytes(stream);
113+
if (bytes == null) {
114114
LOG.warn("Failed to read first bytes from file");
115115
return false;
116116
}
117117

118-
if (isJpeg(firstBytes) || isPng(firstBytes)) {
118+
if (isJpeg(bytes) || isPng(bytes)) {
119119
return true;
120120
}
121121

122122
if (LOG.isDebugEnabled()) {
123-
LOG.debug(
124-
"Looks like file isn't an image. First bytes: {}",
125-
formatBytes(firstBytes)
126-
);
123+
LOG.debug("Looks like file isn't an image. First bytes: {}", formatBytes(bytes));
127124
}
128125

129126
return false;

0 commit comments

Comments
 (0)