|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2011 the original author or authors. |
| 2 | + * Copyright 2002-2012 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -247,20 +247,30 @@ private class LifecycleMetadata {
|
247 | 247 | public LifecycleMetadata(Class<?> targetClass, Collection<LifecycleElement> initMethods,
|
248 | 248 | Collection<LifecycleElement> destroyMethods) {
|
249 | 249 |
|
250 |
| - this.initMethods = Collections.synchronizedSet(new LinkedHashSet<LifecycleElement>()); |
251 |
| - for (LifecycleElement element : initMethods) { |
252 |
| - if (logger.isDebugEnabled()) { |
253 |
| - logger.debug("Found init method on class [" + targetClass.getName() + "]: " + element); |
| 250 | + if (!initMethods.isEmpty()) { |
| 251 | + this.initMethods = Collections.synchronizedSet(new LinkedHashSet<LifecycleElement>(initMethods.size())); |
| 252 | + for (LifecycleElement element : initMethods) { |
| 253 | + if (logger.isDebugEnabled()) { |
| 254 | + logger.debug("Found init method on class [" + targetClass.getName() + "]: " + element); |
| 255 | + } |
| 256 | + this.initMethods.add(element); |
254 | 257 | }
|
255 |
| - this.initMethods.add(element); |
| 258 | + } |
| 259 | + else { |
| 260 | + this.initMethods = Collections.emptySet(); |
256 | 261 | }
|
257 | 262 |
|
258 |
| - this.destroyMethods = Collections.synchronizedSet(new LinkedHashSet<LifecycleElement>()); |
259 |
| - for (LifecycleElement element : destroyMethods) { |
260 |
| - if (logger.isDebugEnabled()) { |
261 |
| - logger.debug("Found destroy method on class [" + targetClass.getName() + "]: " + element); |
| 263 | + if (!destroyMethods.isEmpty()) { |
| 264 | + this.destroyMethods = Collections.synchronizedSet(new LinkedHashSet<LifecycleElement>(destroyMethods.size())); |
| 265 | + for (LifecycleElement element : destroyMethods) { |
| 266 | + if (logger.isDebugEnabled()) { |
| 267 | + logger.debug("Found destroy method on class [" + targetClass.getName() + "]: " + element); |
| 268 | + } |
| 269 | + this.destroyMethods.add(element); |
262 | 270 | }
|
263 |
| - this.destroyMethods.add(element); |
| 271 | + } |
| 272 | + else { |
| 273 | + this.destroyMethods = Collections.emptySet(); |
264 | 274 | }
|
265 | 275 | }
|
266 | 276 |
|
|
0 commit comments