Description
My Project Name: AAAA
My Chain Name: AAAA
In one instance I tried to update an existing job to have the name AAAA. I got a validation error. I should theoretically be able to name my plan like this shouldn't I?
During an attempt to reproduce the above behaviour, I tried to create a new Job with the name AAAA. This submitted successfully. However now I get a whole bunch of other exceptions:
2010-09-30 10:17:41,755 ERROR [1638360365@qtp-1196121930-6] [FiveOhOh] 500 Exception was thrown.
org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2
at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:590)
at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337)
at com.atlassian.bamboo.plan.PlanHibernateDao.getPlanByName(PlanHibernateDao.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
The getPlanByName method only looks at the project name and plan name in the build table. And hence will return both the chain and the job.
So we need to either
a) prevent people from creating jobs with the same name as a plan (though this behaves the opposite to how we handle the keys)
b) fix the getPlanByName method, and any other use cases which die because of the duplication.