File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
opengrok-web/src/main/java/org/opengrok/web Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 25
25
import org .opengrok .indexer .configuration .RuntimeEnvironment ;
26
26
import org .opengrok .indexer .history .RepositoryInfo ;
27
27
import org .opengrok .indexer .util .ClassUtil ;
28
- import org .opengrok .web .util .DTO ;
28
+ import org .opengrok .web .util .DTOUtil ;
29
29
30
30
import javax .ws .rs .GET ;
31
31
import javax .ws .rs .Path ;
@@ -45,7 +45,7 @@ public class RepositoriesController {
45
45
private Object getRepositoryInfoData (String repositoryPath ) {
46
46
for (RepositoryInfo ri : env .getRepositories ()) {
47
47
if (ri .getDirectoryNameRelative ().equals (repositoryPath )) {
48
- return DTO .createDTO (ri );
48
+ return DTOUtil .createDTO (ri );
49
49
}
50
50
}
51
51
Original file line number Diff line number Diff line change 28
28
29
29
import java .lang .reflect .Field ;
30
30
31
- public class DTO {
32
- private DTO () {
31
+ public class DTOUtil {
32
+ private DTOUtil () {
33
33
// private to ensure static
34
34
}
35
35
36
+ // ModelMapper is thread-safe and we only need to convert different object types for now
37
+ // so it should be safe to reuse its instance.
38
+ private static final ModelMapper modelMapper = new ModelMapper ();
39
+
36
40
/**
37
41
* Generate Data Transfer Object from an object. Any field in the input object
38
42
* that is annotated with <code>DTOElement</code> will be brought along.
@@ -49,7 +53,6 @@ public static Object createDTO(Object object) {
49
53
}
50
54
Object bean = beanGenerator .create ();
51
55
52
- ModelMapper modelMapper = new ModelMapper ();
53
56
return modelMapper .map (object , bean .getClass ());
54
57
}
55
58
}
You can’t perform that action at this time.
0 commit comments