{"action":"created","issue":{"url":"https://api.github.com/repos/prometheus/jmx_exporter/issues/267","repository_url":"https://api.github.com/repos/prometheus/jmx_exporter","labels_url":"https://api.github.com/repos/prometheus/jmx_exporter/issues/267/labels{/name}","comments_url":"https://api.github.com/repos/prometheus/jmx_exporter/issues/267/comments","events_url":"https://api.github.com/repos/prometheus/jmx_exporter/issues/267/events","html_url":"https://github.com/prometheus/jmx_exporter/issues/267","id":317528894,"number":267,"title":"StackOverflowError in JmxScraper","user":{"login":"aukevanleeuwen","id":301092,"avatar_url":"https://avatars2.githubusercontent.com/u/301092?v=4","gravatar_id":"","url":"https://api.github.com/users/aukevanleeuwen","html_url":"https://github.com/aukevanleeuwen","followers_url":"https://api.github.com/users/aukevanleeuwen/followers","following_url":"https://api.github.com/users/aukevanleeuwen/following{/other_user}","gists_url":"https://api.github.com/users/aukevanleeuwen/gists{/gist_id}","starred_url":"https://api.github.com/users/aukevanleeuwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aukevanleeuwen/subscriptions","organizations_url":"https://api.github.com/users/aukevanleeuwen/orgs","repos_url":"https://api.github.com/users/aukevanleeuwen/repos","events_url":"https://api.github.com/users/aukevanleeuwen/events{/privacy}","received_events_url":"https://api.github.com/users/aukevanleeuwen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-04-25T08:33:32Z","updated_at":"2018-04-30T13:04:52Z","closed_at":"2018-04-30T12:03:41Z","author_association":"CONTRIBUTOR","body":"Once in a while, while scraping I'm getting the following exception. I've only once been able to reproduce it reliably, however I was not able to debug which value triggered it. (Once I started debugging it never showed up again). \r\n\r\nI'm pretty sure this StackOverflow answer hits the nail on the head: https://stackoverflow.com/questions/7509905/java-lang-stackoverflowerror-while-using-a-regex-to-parse-big-strings\r\n\r\n> Unfortunately, Java's builtin regex support has problems with regexes containing repetitive alternative paths (that is, (A|B)*). This is compiled into a recursive call, which results in a StackOverflow error when used on a very large string.\r\n\r\nThis is the `Pattern`:\r\n\r\n```java\r\nPattern.compile(\r\n                \"([^,=:\\\\*\\\\?]+)\" + // Name - non-empty, anything but comma, equals, colon, star, or question mark\r\n                        \"=\" +  // Equals\r\n                        \"(\" + // Either\r\n                        \"\\\"\" + // Quoted\r\n                        \"(?:\" + // A possibly empty sequence of\r\n                        \"[^\\\\\\\\\\\"]\" + // Anything but backslash or quote\r\n                        \"|\\\\\\\\\\\\\\\\\" + // or an escaped backslash\r\n                        \"|\\\\\\\\n\" + // or an escaped newline\r\n                        \"|\\\\\\\\\\\"\" + // or an escaped quote\r\n                        \"|\\\\\\\\\\\\?\" + // or an escaped question mark\r\n                        \"|\\\\\\\\\\\\*\" + // or an escaped star\r\n                        \")*\" +\r\n                        \"\\\"\" +\r\n                        \"|\" + // Or\r\n                        \"[^,=:\\\"]*\" + // Unquoted - can be empty, anything but comma, equals, colon, or quote\r\n                        \")\");\r\n```\r\n\r\nI don't understand the pattern completely, but the middle part is a likely suspect. \r\n\r\nI'll try to dig in a bit, but maybe you can give me a few words on what exactly we're trying to match here. Do you have some example Strings you're trying to match?\r\n\r\n---\r\n```\r\nException in thread \"pool-1-thread-2\" java.lang.StackOverflowError\r\n\tat java.util.regex.Pattern$Loop.match(Pattern.java:4785)\r\n\tat java.util.regex.Pattern$GroupTail.match(Pattern.java:4717)\r\n\tat java.util.regex.Pattern$BranchConn.match(Pattern.java:4568)\r\n\r\n\t... some 1400 lines ....\r\n\r\n\tat java.util.regex.Pattern$CharProperty.match(Pattern.java:3777)\r\n\tat java.util.regex.Pattern$Branch.match(Pattern.java:4604)\r\n\tat java.util.regex.Pattern$GroupHead.match(Pattern.java:4658)\r\n\tat java.util.regex.Pattern$Loop.matchInit(Pattern.java:4804)\r\n\tat java.util.regex.Pattern$Prolog.match(Pattern.java:4741)\r\n\tat java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3798)\r\n\tat java.util.regex.Pattern$Branch.match(Pattern.java:4604)\r\n\tat java.util.regex.Pattern$GroupHead.match(Pattern.java:4658)\r\n\tat java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3798)\r\n\tat java.util.regex.Pattern$GroupTail.match(Pattern.java:4717)\r\n\tat java.util.regex.Pattern$Curly.match0(Pattern.java:4272)\r\n\tat java.util.regex.Pattern$Curly.match(Pattern.java:4234)\r\n\tat java.util.regex.Pattern$GroupHead.match(Pattern.java:4658)\r\n\tat java.util.regex.Matcher.match(Matcher.java:1270)\r\n\tat java.util.regex.Matcher.lookingAt(Matcher.java:682)\r\n\tat io.prometheus.jmx.shaded.io.prometheus.jmx.JmxScraper.getKeyPropertyList(JmxScraper.java:178)\r\n\tat io.prometheus.jmx.shaded.io.prometheus.jmx.JmxScraper.scrapeBean(JmxScraper.java:161)\r\n\tat io.prometheus.jmx.shaded.io.prometheus.jmx.JmxScraper.doScrape(JmxScraper.java:120)\r\n\tat io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.collect(JmxCollector.java:415)\r\n\tat io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:180)\r\n\tat io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:213)\r\n\tat io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:134)\r\n\tat io.prometheus.jmx.shaded.io.prometheus.client.exporter.common.TextFormat.write004(TextFormat.java:22)\r\n\tat io.prometheus.jmx.shaded.io.prometheus.client.exporter.HTTPServer$HTTPMetricHandler.handle(HTTPServer.java:43)\r\n\tat com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)\r\n\tat sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)\r\n\tat com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)\r\n\tat sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)\r\n\tat com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)\r\n\tat sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\r\n\tat java.lang.Thread.run(Thread.java:748)\r\n```"},"comment":{"url":"https://api.github.com/repos/prometheus/jmx_exporter/issues/comments/385392201","html_url":"https://github.com/prometheus/jmx_exporter/issues/267#issuecomment-385392201","issue_url":"https://api.github.com/repos/prometheus/jmx_exporter/issues/267","id":385392201,"user":{"login":"aukevanleeuwen","id":301092,"avatar_url":"https://avatars2.githubusercontent.com/u/301092?v=4","gravatar_id":"","url":"https://api.github.com/users/aukevanleeuwen","html_url":"https://github.com/aukevanleeuwen","followers_url":"https://api.github.com/users/aukevanleeuwen/followers","following_url":"https://api.github.com/users/aukevanleeuwen/following{/other_user}","gists_url":"https://api.github.com/users/aukevanleeuwen/gists{/gist_id}","starred_url":"https://api.github.com/users/aukevanleeuwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aukevanleeuwen/subscriptions","organizations_url":"https://api.github.com/users/aukevanleeuwen/orgs","repos_url":"https://api.github.com/users/aukevanleeuwen/repos","events_url":"https://api.github.com/users/aukevanleeuwen/events{/privacy}","received_events_url":"https://api.github.com/users/aukevanleeuwen/received_events","type":"User","site_admin":false},"created_at":"2018-04-30T13:04:52Z","updated_at":"2018-04-30T13:04:52Z","author_association":"CONTRIBUTOR","body":"Okay, thanks for the merge. Will have a look next week.\r\n\r\nBtw, the version number change from `x.y` to `y.x.z` didn't work out well unfortunately. You effectively went back in time (versioning wise) from `0.10(.0)` to `0.1.0`. \r\n\r\nPeople that are searching for new artifacts via maven repositories for example will not see any newer versions 'by default' since the latest one shows as `0.10`. \r\n\r\nSee for example here: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.prometheus.jmx%22%20a%3A%22jmx_prometheus_javaagent%22\r\n\r\nJust wanted to let you know, in case you didn't realise this unwanted side-effect."}}
{"actor":{"display_login":"aukevanleeuwen"}}