Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

NullPointerException when trying to add a rewrite #229

Open
evgkirov opened this issue Feb 20, 2020 · 0 comments
Open

NullPointerException when trying to add a rewrite #229

evgkirov opened this issue Feb 20, 2020 · 0 comments

Comments

@evgkirov
Copy link

Describe the bug
browserup-proxy throws me a 500 Server Error when I'm trying to add a rewrite via REST API.

To Reproduce

$ docker run -p 28700:8080 autifyhq/browserup-proxy:2.0.1
$ curl -v -X "POST" "http://127.0.0.1:28700/proxy"
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 28700 (#0)
> POST /proxy HTTP/1.1
> Host: 127.0.0.1:28700
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Thu, 20 Feb 2020 16:48:30 GMT
< Content-Type: application/json
< Content-Length: 13
< Server: Jetty(9.4.20.v20190813)
< 
* Connection #0 to host 127.0.0.1 left intact
{"port":8081}* Closing connection 0
$ curl -v -X "PUT" "http://127.0.0.1:28700/proxy/8081/rewrite" \
>      -H 'Content-Type: application/json; charset=utf-8' \
>      -d $'{
>   "replace": "222",
>   "matchRegex": "111"
> }'
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 28700 (#0)
> PUT /proxy/8081/rewrite HTTP/1.1
> Host: 127.0.0.1:28700
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Type: application/json; charset=utf-8
> Content-Length: 45
> 
* upload completely sent off: 45 out of 45 bytes
< HTTP/1.1 500 Server Error
< Connection: close
< Server: Jetty(9.4.20.v20190813)
< 
* Closing connection 0
Running BrowserUp Proxy, powered by LittleProxy.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/browserup-proxy-2.0.1/lib/guice-4.2.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO  2020-02-20T16:48:25,031 com.browserup.bup.proxy.Main] (main) Starting BrowserUp Proxy version ${project.version} 
[INFO  2020-02-20T16:48:25,084 org.eclipse.jetty.util.log] (main) Logging initialized @1093ms to org.eclipse.jetty.util.log.Slf4jLog 
[INFO  2020-02-20T16:48:25,187 org.eclipse.jetty.server.Server] (main) jetty-9.4.20.v20190813; built: 2019-08-13T21:28:18.144Z; git: 84700530e645e812b336747464d6fbbf370c9a20; jvm 14-ea+15 
[INFO  2020-02-20T16:48:25,243 org.eclipse.jetty.server.session] (main) DefaultSessionIdManager workerName=node0 
[INFO  2020-02-20T16:48:25,243 org.eclipse.jetty.server.session] (main) No SessionScavenger set, using defaults 
[INFO  2020-02-20T16:48:25,246 org.eclipse.jetty.server.session] (main) node0 Scavenging every 660000ms 
Feb 20, 2020 4:48:25 PM org.glassfish.jersey.internal.inject.Providers checkProviderRuntime
WARNING: A provider io.swagger.v3.jaxrs2.integration.resources.OpenApiResource registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER runtime. Due to constraint configuration problems the provider io.swagger.v3.jaxrs2.integration.resources.OpenApiResource will be ignored. 
[INFO  2020-02-20T16:48:25,896 org.hibernate.validator.internal.util.Version] (main) HV000001: Hibernate Validator 6.0.17.Final 
[INFO  2020-02-20T16:48:26,076 org.eclipse.jetty.server.handler.ContextHandler] (main) Started o.e.j.s.ServletContextHandler@707ca986{/,null,AVAILABLE} 
[INFO  2020-02-20T16:48:26,092 org.eclipse.jetty.server.AbstractConnector] (main) Started ServerConnector@44afefd5{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} 
[INFO  2020-02-20T16:48:26,093 org.eclipse.jetty.server.Server] (main) Started @2103ms 
[INFO  2020-02-20T16:48:30,474 com.browserup.bup.proxy.bricks.ProxyResource] (qtp654740048-18) POST / 
[INFO  2020-02-20T16:48:30,476 com.browserup.bup.proxy.bricks.ProxyResource] (qtp654740048-18) {} 
[INFO  2020-02-20T16:48:31,154 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp654740048-18) Starting proxy at address: 0.0.0.0/0.0.0.0:8081 
[INFO  2020-02-20T16:48:31,181 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp654740048-18) Proxy listening with TCP transport 
[INFO  2020-02-20T16:48:31,255 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp654740048-18) Proxy started at address: /0.0.0.0:8081 
[INFO  2020-02-20T16:48:39,284 com.browserup.bup.proxy.bricks.ProxyResource] (qtp654740048-13) PUT /8084/rewrite 
[INFO  2020-02-20T16:48:46,484 com.browserup.bup.proxy.bricks.ProxyResource] (qtp654740048-14) PUT /8081/rewrite 
[WARN  2020-02-20T16:48:46,488 org.eclipse.jetty.server.HttpChannel] (qtp654740048-14) /proxy/8081/rewrite com.google.sitebricks.routing.EventDispatchException: Exception [NullPointerException - "null"] thrown by event method [public com.google.sitebricks.headless.Reply com.browserup.bup.proxy.bricks.ProxyResource.rewriteUrl(int,com.google.sitebricks.headless.Request)]

at java.base/java.util.regex.Pattern.<init>(Pattern.java:1429)
(See below for entire trace.)

        at com.google.sitebricks.routing.DefaultPageBook$MethodTuple.call(DefaultPageBook.java:830) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.routing.DefaultPageBook$MethodTuple.call(DefaultPageBook.java:805) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.routing.DefaultPageBook$PageTuple.callAction(DefaultPageBook.java:624) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.routing.DefaultPageBook$PageTuple.doMethod(DefaultPageBook.java:603) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.routing.WidgetRoutingDispatcher.fireEvent(WidgetRoutingDispatcher.java:171) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.routing.WidgetRoutingDispatcher.bindAndReply(WidgetRoutingDispatcher.java:102) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.routing.WidgetRoutingDispatcher.dispatch(WidgetRoutingDispatcher.java:88) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.DebugModeRoutingDispatcher.dispatch(DebugModeRoutingDispatcher.java:56) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.SitebricksFilter.doFilter(SitebricksFilter.java:62) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.HiddenMethodFilter.doFilter(HiddenMethodFilter.java:70) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121) ~[guice-servlet-4.2.2.jar:?]
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133) ~[guice-servlet-4.2.2.jar:?]
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1591) ~[jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:542) ~[jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) ~[jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.Server.handle(Server.java:494) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) ~[jetty-io-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) ~[jetty-io-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) ~[jetty-io-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) ~[jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) ~[jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) ~[jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135) ~[jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
        at java.lang.Thread.run(Thread.java:830) [?:?]
Caused by: java.lang.reflect.InvocationTargetException
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
        at com.google.sitebricks.routing.DefaultPageBook$MethodTuple.call(DefaultPageBook.java:820) ~[sitebricks-0.8.11.jar:0.8.11]
        ... 37 more
Caused by: java.lang.NullPointerException
        at java.util.regex.Pattern.<init>(Pattern.java:1429) ~[?:?]
        at java.util.regex.Pattern.compile(Pattern.java:1070) ~[?:?]
        at com.browserup.bup.proxy.RewriteRule.<init>(RewriteRule.java:17) ~[browserup-proxy-core-2.0.1.jar:?]
        at com.browserup.bup.BrowserUpProxyServer.rewriteUrl(BrowserUpProxyServer.java:795) ~[browserup-proxy-core-2.0.1.jar:?]
        at com.browserup.bup.proxy.bricks.ProxyResource.rewriteUrl(ProxyResource.java:582) ~[browserup-proxy-rest-2.0.1.jar:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
        at com.google.sitebricks.routing.DefaultPageBook$MethodTuple.call(DefaultPageBook.java:820) ~[sitebricks-0.8.11.jar:0.8.11]
        ... 37 more


Expected behavior
It shouldn't fail or at least it should show a meaningful error message.

Please complete the following information:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant