# HG changeset patch # User Dmitry Neverov # Date 1355745159 -14400 # Node ID 2ffa2c6cbaa49810481161de2632ea013d4bde99 # Parent 686b04d58c6e8890adabad87d3f4713319e843f6# Parent 64d3b1f5ae6b438f9d241e280539f5d1a5b5dc2a Merge branch Faradi-7.1.x diff -r 686b04d58c6e -r 2ffa2c6cbaa4 mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/MercurialXmlLogParser.java --- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/MercurialXmlLogParser.java Thu Dec 13 12:43:31 2012 +0400 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/MercurialXmlLogParser.java Mon Dec 17 15:52:39 2012 +0400 @@ -18,7 +18,7 @@ public class MercurialXmlLogParser extends DefaultHandler { private static final String DATE_FORMAT = "EEE MMM d HH:mm:ss yyyy Z"; - private static final SimpleDateFormat ourSimpleDateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH); + private final SimpleDateFormat mySimpleDateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH); private List myChangeSets = new ArrayList(); private ChangeSet myCset = null; private StringBuilder myText = new StringBuilder(); @@ -81,7 +81,7 @@ private Date parseDate() throws SAXException { try { - return ourSimpleDateFormat.parse(getText()); + return mySimpleDateFormat.parse(getText()); } catch (ParseException e) { throw new SAXException(e); } diff -r 686b04d58c6e -r 2ffa2c6cbaa4 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialXmlLogParserTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialXmlLogParserTest.java Mon Dec 17 15:52:39 2012 +0400 @@ -0,0 +1,61 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial; + +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.MercurialXmlLogParser; +import jetbrains.buildServer.util.TestFor; +import org.testng.annotations.Test; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.*; + +@Test +public class MercurialXmlLogParserTest { + + @TestFor(issues = {"TW-24864", "TW-24214"}) + public void parse_date() throws Exception { + final SAXParserFactory saxFactory = SAXParserFactory.newInstance(); + final List errors = new ArrayList(); + final CountDownLatch countDown = new CountDownLatch(1); + Runnable parseLog = new Runnable() { + public void run() { + try { + countDown.await(); + MercurialXmlLogParser parser = new MercurialXmlLogParser(); + SAXParser saxParser = saxFactory.newSAXParser(); + String logOutput = + "" + + "" + + "" + + "" + + "" + + "Fri Dec 14 12:22:31 2012 +0100" + + "Fix SDK installer." + + "" + + ".hgsubstate" + + "" + + "" + + ""; + saxParser.parse(new ByteArrayInputStream(logOutput.getBytes("UTF-8")), parser); + parser.getChangeSets(); + } catch (Exception e) { + errors.add(e); + } + } + }; + + ExecutorService exec = Executors.newFixedThreadPool(10); + for (int i = 0; i < 10; i++) + exec.execute(parseLog); + + countDown.countDown(); + exec.shutdown(); + exec.awaitTermination(10, TimeUnit.SECONDS); + + if (!errors.isEmpty()) + throw errors.get(0); + } + +} diff -r 686b04d58c6e -r 2ffa2c6cbaa4 mercurial-tests/src/testng.xml --- a/mercurial-tests/src/testng.xml Thu Dec 13 12:43:31 2012 +0400 +++ b/mercurial-tests/src/testng.xml Mon Dec 17 15:52:39 2012 +0400 @@ -28,6 +28,7 @@ +