Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exeption when editing repository #1389

Open
TomaszSzt opened this issue Nov 5, 2021 · 0 comments
Open

Exeption when editing repository #1389

TomaszSzt opened this issue Nov 5, 2021 · 0 comments

Comments

@TomaszSzt
Copy link
Contributor

TomaszSzt commented Nov 5, 2021

Under a very specific conditions following exception do happen:

org.apache.wicket.WicketRuntimeException: Error setting field value of field public int com.gitblit.models.RepositoryModel.maxActivityCommits on object dd, value null
at org.apache.wicket.util.lang.PropertyResolver$FieldGetAndSetter.setValue(PropertyResolver.java:1393)
at org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(PropertyResolver.java:641)
at org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:141)
at org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractPropertyModel.java:182)
at org.apache.wicket.Component.setDefaultModelObject(Component.java:3170)
at org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1183)
at org.apache.wicket.markup.html.form.Form$FormModelUpdateVisitor.component(Form.java:231)
at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:519)
at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:498)
at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:498)
at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrder(FormComponent.java:470)
at org.apache.wicket.markup.html.form.Form.internalUpdateFormComponentModels(Form.java:2158)
at org.apache.wicket.markup.html.form.Form.updateFormComponentModels(Form.java:2126)
at org.apache.wicket.markup.html.form.Form.process(Form.java:1051)
at org.apache.wicket.markup.html.form.Form.process(Form.java:957)
at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:922)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182)
at org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1279)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1358)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1465)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:88)
at com.gitblit.servlet.EnforceAuthenticationFilter.doFilter(EnforceAuthenticationFilter.java:99)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:88)
at com.gitblit.servlet.ProxyFilter$1.doFilter(ProxyFilter.java:89)
at com.gitblit.servlet.ProxyFilter.doFilter(ProxyFilter.java:92)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:88)
at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120)
at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:133)
at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:130)
at com.google.inject.servlet.GuiceFilter$Context.call(GuiceFilter.java:203)
at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:130)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Can not set int field com.gitblit.models.RepositoryModel.maxActivityCommits to null value
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeIntegerFieldAccessorImpl.set(Unknown Source)
at java.lang.reflect.Field.set(Unknown Source)
at org.apache.wicket.util.lang.PropertyResolver$FieldGetAndSetter.setValue(PropertyResolver.java:1389)
... 57 more

Branch: master

Steps to reproduce:
1.Prepare a GitBlit server with "web.maxActivityCommits=0" configuration option.
2.Start it, create a repository.
3.Stop server.
4.Change configuration option to: "web.maxActivityCommits=5"
5.Start server
6.Enter the repository, select "Edit". Touch just first "general" tab, change description, click "save".
7.Observe internal error and above log dump to console.
8.Stop server, retry it few times. Error should be consequently present.
9.Change configuration option to: "web.maxActivityCommits=25" and start server.
10.Again edit description and click save. Observe that no errors do happen.

Investigation
In step 6 check the "miscellaneous"' and the "max activity commits" selection. You will notice that there is "Choose one". This is the culprit.

In EditRepositoryPage.java
line 573 one can see:

List<Integer> maxActivityCommits  = Arrays.asList(-1, 0, 25, 50, 75, 100, 150, 200, 250, 500);
	form.add(new ChoiceOption<Integer>("maxActivityCommits",
			getString("gb.maxActivityCommits"),
			getString("gb.maxActivityCommitsDescription"),
			new DropDownChoice<Integer>("choice",
					new PropertyModel<Integer>(repositoryModel, "maxActivityCommits"),
					maxActivityCommits,
					new MaxActivityCommitsRenderer())));

I can't understand how exactly Wicket does it due to as it seems reflections being used to manipulate objects, but I do suspect that it happens because 5 is not on the list and zero must have a special meaning.

Work around:
1.Before save enter "miscellaneous" and select value other than "Choose one", or
2.Use web.maxActivityCommits only of that listed in above code snippet.

TomaszSzt added a commit to TomaszSzt/gitblit that referenced this issue Nov 5, 2021
regarding peculiar problem after server upgrade when  web.maxActivityCommits
is modified in server configuration to not be one of -1, 0, 25, 50, 75, 100, 150, 200, 250, 500.

The detailed and exact code line which is responsible for why this happens is something beond my understanding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant