Skip to content

Commit 14eafe3

Browse files
committed
fixed primitive types bug in processor
1 parent 52f7af7 commit 14eafe3

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

processor/src/main/kotlin/ru/nsu/kcache/KCacheableProcessor.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ package ru.nsu.kcache
33
import com.google.auto.service.AutoService
44
import ru.nsu.kcache.creator.HandlerMetadataContainerCreator
55
import ru.nsu.manasyan.kcache.core.annotations.KCacheable
6-
import java.nio.file.Path
76
import java.nio.file.Paths
87
import javax.annotation.processing.*
98
import javax.lang.model.SourceVersion
109
import javax.lang.model.element.ExecutableElement
1110
import javax.lang.model.element.TypeElement
11+
import javax.lang.model.type.DeclaredType
1212
import javax.lang.model.type.MirroredTypeException
1313
import javax.lang.model.util.Elements
1414
import javax.lang.model.util.Types
1515
import javax.tools.Diagnostic
1616

17+
1718
typealias KCacheableMetadata = MutableMap<String, RequestHandlerMetadata>
1819

1920
@AutoService(Processor::class)
@@ -89,7 +90,10 @@ class KCacheableProcessor : AbstractProcessor() {
8990
separator = ",",
9091
postfix = ")"
9192
) {
92-
typeUtils.asElement(it.asType()).toString()
93+
when (val type = it.asType()) {
94+
is DeclaredType -> typeUtils.asElement(type)
95+
else -> type
96+
}.toString()
9397
}
9498

9599
kCacheableMetadata["$enclosingName.${element.simpleName}$parameters"] =

test-web-app/src/main/java/com/example/app/controller/SingleUserController.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
package com.example.app.controller;
22

3-
import com.example.app.data.TestUser;
43
import com.example.app.service.TestUserService;
54
import org.springframework.http.RequestEntity;
65
import org.springframework.http.ResponseEntity;
7-
import org.springframework.web.bind.annotation.GetMapping;
8-
import org.springframework.web.bind.annotation.PathVariable;
9-
import org.springframework.web.bind.annotation.RequestMapping;
10-
import org.springframework.web.bind.annotation.RestController;
6+
import org.springframework.web.bind.annotation.*;
117
import ru.nsu.manasyan.kcache.core.annotations.KCacheable;
128

139
@RestController
@@ -25,6 +21,7 @@ public SingleUserController(TestUserService service) {
2521
)
2622
public ResponseEntity<?> getUserById(
2723
@PathVariable String id,
24+
@RequestParam(value = "limit", defaultValue = "20") int limit,
2825
RequestEntity<?> requestEntity
2926
) {
3027
return ResponseEntity.ok(service.getUser(id));

0 commit comments

Comments
 (0)