Source:
<code>public List<DBVersion> getChangelogVersions(String currentDBVersion, String fileName) throws InternalErrorException { Pattern versionPattern = Pattern.compile("^[1-9][0-9]*[.][0-9]+[.][0-9]+"); Pattern commentPattern = Pattern.compile("^--.*"); List<DBVersion> versions = new ArrayList<>(); boolean versionFound = false; <START> try(BufferedReader br = new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream(fileName)))) { <END> String line = br.readLine(); while (line != null){ line = line.trim(); if(line.isEmpty() || commentPattern.matcher(line).matches()) { line = br.readLine(); continue; } if(versionPattern.matcher(line).matches()){ DBVersion version = new DBVersion(line); if(!versions.isEmpty()) { DBVersion previousVersion = versions.get(versions.size() - 1); if(version.compareTo(previousVersion) >= 0) { throw new InternalErrorException("Version numbers in changelog file are not increasing properly. " + "Version " + previousVersion.getVersion() + " should be higher than " + version.getVersion()); } } if(line.equals(currentDBVersion)){ versionFound = true; break; } List<String> commands = new ArrayList<>(); while((line = br.readLine()) != null) { line = line.trim(); if(line.isEmpty()) { break; } commands.add(line); } version.setCommands(commands); versions.add(version); } else { throw new InternalErrorException("Version does not match the pattern required in " + fileName); } } if(!versionFound) { throw new InternalErrorException("Version " + currentDBVersion + " not found in " + fileName); } } catch(IOException e) { throw new InternalErrorException("Error reading " + fileName, e); } return versions; }</code><technical_language>testing devel I a problem ClassLoader in WAR file. In tests is jar file problem defined classloader. In WAR file need specific ClassLoader used. this instead: Resource resource = new ClassPathResource(fileName); try(BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()))) { ... }</technical_language>

Target:
public List<DBVersion> getChangelogVersions(String currentDBVersion, String fileName) throws InternalErrorException { Pattern versionPattern = Pattern.compile("^[1-9][0-9]*[.][0-9]+[.][0-9]+"); Pattern commentPattern = Pattern.compile("^--.*"); List<DBVersion> versions = new ArrayList<>(); boolean versionFound = false; Resource resource = new ClassPathResource(fileName); try(BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()))) { String line = br.readLine(); while (line != null){ line = line.trim(); if(line.isEmpty() || commentPattern.matcher(line).matches()) { line = br.readLine(); continue; } if(versionPattern.matcher(line).matches()){ DBVersion version = new DBVersion(line); if(!versions.isEmpty()) { DBVersion previousVersion = versions.get(versions.size() - 1); if(version.compareTo(previousVersion) >= 0) { throw new InternalErrorException("Version numbers in changelog file are not increasing properly. " + "Version " + previousVersion.getVersion() + " should be higher than " + version.getVersion()); } } if(line.equals(currentDBVersion)){ versionFound = true; break; } List<String> commands = new ArrayList<>(); while((line = br.readLine()) != null) { line = line.trim(); if(line.isEmpty()) { break; } commands.add(line); } version.setCommands(commands); versions.add(version); } else { throw new InternalErrorException("Version does not match the pattern required in " + fileName); } } if(!versionFound) { throw new InternalErrorException("Version " + currentDBVersion + " not found in " + fileName); } } catch(IOException e) { throw new InternalErrorException("Error reading " + fileName, e); } return versions; }