mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-22 13:58:20 +00:00
Fix Checksum calculate() with special characters
(cherry picked from commit e9efd5a702)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package io.ebeaninternal.dbmigration;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
@@ -13,9 +14,8 @@ class MChecksum {
|
||||
* Returns the checksum of the file. Agnostic of encoding and new line character.
|
||||
*/
|
||||
static int calculate(File file) {
|
||||
try {
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8")))) {
|
||||
final CRC32 crc32 = new CRC32();
|
||||
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
final byte[] lineBytes = line.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
@@ -10,9 +10,9 @@ public class MChecksumTest {
|
||||
|
||||
@Test
|
||||
public void calculate() {
|
||||
File file = new File("src/test/resources/dbmigration/index/1.0__hello.sql");
|
||||
File file = new File("src/test/resources/dbmigration/index-special-chars/1.0__hello.sql");
|
||||
assertThat(file).exists();
|
||||
|
||||
assertThat(MChecksum.calculate(file)).isEqualTo(907060870);
|
||||
assertThat(MChecksum.calculate(file)).isEqualTo(1859426839);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
helloäüü
|
||||
Reference in New Issue
Block a user