Skip to content
Permalink
Browse files

[FIXED JENKINS-17762] Replace old parser names with new names.

During de-serialization the old parser names should be replaced 
with the new names otherwise the UI can't show the selected parser.
  • Loading branch information
uhafner committed May 1, 2013
1 parent 6c343de commit 475666b83c000825c518b5dfc1f60e7202d4ba66
@@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -197,9 +198,46 @@ protected Object readResolve() {
}
}

replaceConsoleParsersWithChangedName();
replaceFileParsersWithChangedName();

return this;
}

private void replaceConsoleParsersWithChangedName() {
List<ConsoleParser> updatedConsoleParsers = new ArrayList<ConsoleParser>(consoleParsers);
for (ConsoleParser parser : consoleParsers) {
String parserName = parser.getParserName();
if (ParserRegistry.exists(parserName)) {
String group = getGroup(parserName);
if (!group.equals(parserName)) {
updatedConsoleParsers.remove(parser);
updatedConsoleParsers.add(new ConsoleParser(group));
}
}
consoleParsers = updatedConsoleParsers;
}
}

private void replaceFileParsersWithChangedName() {
List<ParserConfiguration> updatedFileParsers = new ArrayList<ParserConfiguration>(parserConfigurations);
for (ParserConfiguration parser : parserConfigurations) {
String parserName = parser.getParserName();
if (ParserRegistry.exists(parserName)) {
String group = getGroup(parserName);
if (!group.equals(parserName)) {
updatedFileParsers.remove(parser);
updatedFileParsers.add(new ParserConfiguration(parser.getPattern(), group));
}
}
parserConfigurations = updatedFileParsers;
}
}

private String getGroup(final String parserName) {
return ParserRegistry.getParser(parserName).getGroup();
}

private void upgradeFrom318() {
consoleLogParsers = Sets.newHashSet();
parserConfigurations = Lists.newArrayList();
@@ -51,6 +51,21 @@ public void testRegistry() {
assertEquals("Wrong mixed API implementations", 1, ParserRegistry.getParsers(MIXED_API).size());
}

/**
* Verifies that the registry detects old and new API extensions and maps them correctly.
*/
@Test
public void testIssue17762() {
String oldClang = "Apple LLVM Compiler (Clang)";
String newClang = "Clang (LLVM based)";

assertEquals("Wrong new API implementations", 1, ParserRegistry.getParsers(oldClang).size());
assertEquals("Wrong old API implementations", 1, ParserRegistry.getParsers(newClang).size());

assertTrue("Parser does not exist: " + oldClang, ParserRegistry.exists(oldClang));
assertTrue("Parser does not exist: " + newClang, ParserRegistry.exists(newClang));
}

/**
* Verifies that we parse two warnings if we use the key of the 3.x version.
*

0 comments on commit 475666b

Please sign in to comment.