team-piazza icon indicating copy to clipboard operation
team-piazza copied to clipboard

Setting Max Portrait Size to 0 crashes plugin

Open shredsandpatches opened this issue 6 years ago • 1 comments

Hello,

Our team had no need for Gravatars, so we tried setting Max Portrait Size to 0px. Unfortunately, this caused Piazza to crash with the following stacktrace:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'piazza' defined in Byte array resource [plugin: team-piazza#team-piazza-server-1.5.jar!/META-INF/build-server-plugin.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.natpryce.piazza.Piazza]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: sizeInPixels needs to be between 1 and 512 
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:275) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) 
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) 
at jetbrains.buildServer.plugins.spring.SpringPluginLoader.pluginClassesLoaded(SpringPluginLoader.java:102) 
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at jetbrains.buildServer.util.EventDispatcher.dispatch(EventDispatcher.java:121) 
at jetbrains.buildServer.util.EventDispatcher$2.invoke(EventDispatcher.java:68) 
at com.sun.proxy.$Proxy16.pluginClassesLoaded(Unknown Source) 
at jetbrains.buildServer.plugins.PluginManagerImpl$2.visitPlugin(PluginManagerImpl.java:140) 
at jetbrains.buildServer.plugins.PluginsCollection$6.run(PluginsCollection.java:257) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
at java.lang.Thread.run(Thread.java:748) 
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.natpryce.piazza.Piazza]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: sizeInPixels needs to be between 1 and 512 
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163) 
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122) 
at jetbrains.buildServer.spring.InstantiationStrategySelector$1.instantiate(InstantiationStrategySelector.java:77) 
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:267) 
... 25 more 
Caused by: java.lang.IllegalArgumentException: sizeInPixels needs to be between 1 and 512 
at com.timgroup.jgravatar.internal.com.google.common.base.Preconditions.checkArgument(Preconditions.java:88) 
at com.timgroup.jgravatar.Gravatar.setSize(Gravatar.java:100) 
at com.natpryce.piazza.PiazzaUserAdapter.determineGravatarUrl(PiazzaUserAdapter.java:86) 
at com.natpryce.piazza.PiazzaUserAdapter.reloadUsers(PiazzaUserAdapter.java:78) 
at com.natpryce.piazza.PiazzaUserAdapter.<init>(PiazzaUserAdapter.java:45) 
at com.natpryce.piazza.Piazza.<init>(Piazza.java:50) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) 
... 28 more

Fortunately we were able to set the portrait size to 1px directly in XML via TeamCity plugin config and restart once our team's builds had all finished but it seems like a minimum pixel value should be specified to avoid this issue in future.

shredsandpatches avatar Dec 01 '17 14:12 shredsandpatches

Thank you for contributing. This is a bug as we expect a value of portrait size.

The current logic is that we force users to have a portrait. When leaving portrait url empty in user settings a random image will be generated by gravatar but only if portrait size is given.

I will create an option in Piazza settings to disable the portraits.

timomeinen avatar Jan 03 '18 10:01 timomeinen