Skip to content

Commit fdb9de1

Browse files
jhoellerunknown
authored and
unknown
committed
Use BufferedInputStream in SimpleMetaDataReader to double performance
Issue: SPR-9528
1 parent 309e51b commit fdb9de1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMetadataReader.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.core.type.classreading;
1818

19+
import java.io.BufferedInputStream;
1920
import java.io.IOException;
2021
import java.io.InputStream;
2122

@@ -38,21 +39,25 @@
3839
final class SimpleMetadataReader implements MetadataReader {
3940

4041
private final Resource resource;
42+
4143
private final ClassMetadata classMetadata;
44+
4245
private final AnnotationMetadata annotationMetadata;
4346

47+
4448
SimpleMetadataReader(Resource resource, ClassLoader classLoader) throws IOException {
45-
InputStream is = resource.getInputStream();
49+
InputStream is = new BufferedInputStream(resource.getInputStream());
4650
ClassReader classReader = null;
4751
try {
4852
classReader = new ClassReader(is);
49-
} finally {
53+
}
54+
finally {
5055
is.close();
5156
}
5257

5358
AnnotationMetadataReadingVisitor visitor = new AnnotationMetadataReadingVisitor(classLoader);
5459
classReader.accept(visitor, true);
55-
60+
5661
this.annotationMetadata = visitor;
5762
// (since AnnotationMetadataReader extends ClassMetadataReadingVisitor)
5863
this.classMetadata = visitor;
@@ -70,4 +75,5 @@ public ClassMetadata getClassMetadata() {
7075
public AnnotationMetadata getAnnotationMetadata() {
7176
return this.annotationMetadata;
7277
}
73-
}
78+
79+
}

0 commit comments

Comments
 (0)