File tree Expand file tree Collapse file tree 6 files changed +30
-37
lines changed
main/java/com/sap/ai/sdk/core
test/java/com/sap/ai/sdk/core
sample-code/spring-app/src/main/resources Expand file tree Collapse file tree 6 files changed +30
-37
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,6 @@ class AiCoreServiceKeyAccessor implements ServiceBindingAccessor {
2929
3030 private final Lazy <Dotenv > dotenv ;
3131
32- static List <ServiceBinding > serviceBindings ;
33-
3432 AiCoreServiceKeyAccessor () {
3533 this (Dotenv .configure ().ignoreIfMissing ().ignoreIfMalformed ());
3634 }
@@ -42,14 +40,6 @@ class AiCoreServiceKeyAccessor implements ServiceBindingAccessor {
4240 @ Nonnull
4341 @ Override
4442 public List <ServiceBinding > getServiceBindings () throws ServiceBindingAccessException {
45- // service bindings are immutable for the lifetime of the application
46- if (serviceBindings == null ) {
47- serviceBindings = fetchServiceBindings ();
48- }
49- return serviceBindings ;
50- }
51-
52- private List <ServiceBinding > fetchServiceBindings () throws ServiceBindingAccessException {
5343 final String serviceKey ;
5444 try {
5545 serviceKey = dotenv .get ().get (ENV_VAR_KEY );
Original file line number Diff line number Diff line change @@ -88,11 +88,13 @@ private T parseSuccess(@Nonnull final ClassicHttpResponse response) throws E {
8888 .getOrElseThrow (e -> exceptionFactory .build (message , e ).setHttpResponse (response ));
8989 try {
9090 final T value = objectMapper .readValue (content , successType );
91- log .info ("Response content: {}" , content );
9291 val timeHeaders = response .getHeaders ("x-upstream-service-time" );
9392 if (timeHeaders .length > 0 ) {
9493 log .info ("LLM request success with duration:{}" , timeHeaders [0 ].getValue ());
94+ } else {
95+ log .info ("LLM request success" );
9596 }
97+ log .debug ("Response content:\n {}" , content );
9698 return value ;
9799 } catch (final JsonProcessingException e ) {
98100 log .error ("Failed to parse response to type {}" , successType );
Original file line number Diff line number Diff line change 99import com .sap .cloud .environment .servicebinding .api .exception .ServiceBindingAccessException ;
1010import io .github .cdimascio .dotenv .Dotenv ;
1111import java .util .Map ;
12- import org .junit .jupiter .api .BeforeEach ;
1312import org .junit .jupiter .api .Test ;
1413
1514class AiCoreServiceKeyAccessorTest {
1615
17- @ BeforeEach
18- void resetServiceBindings () {
19- AiCoreServiceKeyAccessor .serviceBindings = null ;
20- }
21-
2216 @ Test
2317 void testValidDotenv () {
2418 var dotenv = spy (Dotenv .configure ().filename ("valid.testenv" ));
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <configuration >
3+ <property name =" LOG_PATTERN" value =" %d{HH:mm:ss.SSS} %-5level [%thread] %logger{36} - %msg%n" />
4+
5+ <appender name =" CONSOLE" class =" ch.qos.logback.core.ConsoleAppender" >
6+ <encoder class =" ch.qos.logback.classic.encoder.PatternLayoutEncoder" >
7+ <pattern >${LOG_PATTERN}</pattern >
8+ </encoder >
9+ </appender >
10+
11+ <root level =" INFO" >
12+ <appender-ref ref =" CONSOLE" />
13+ </root >
14+
15+ <!-- <logger name="org.apache.hc.client5.http.wire" level="DEBUG"/>-->
16+ <!-- <logger name="org.apache.http.wire" level="DEBUG"/>-->
17+ <logger name =" com.sap.ai.sdk" level =" DEBUG" />
18+ <!-- Disable org.eclipse.jetty logging -->
19+ <logger name =" org.eclipse.jetty" level =" OFF" />
20+ </configuration >
Original file line number Diff line number Diff line change 7171 <javaparser .version>3.27.1</javaparser .version>
7272 <jsonschema-generator .version>4.38.0</jsonschema-generator .version>
7373 <jackson .version>2.20.0</jackson .version>
74+ <logback .version>1.5.20</logback .version>
7475 <!-- conflicts resolution -->
7576 <micrometer .version>1.15.5</micrometer .version>
7677 <json .version>20250517</json .version>
260261 <dependency >
261262 <groupId >ch.qos.logback</groupId >
262263 <artifactId >logback-classic</artifactId >
263- <version >1.5.20 </version >
264+ <version >${logback.version} </version >
264265 <scope >test</scope >
265266 </dependency >
266267 </dependencies >
596597 <groupId >org.apache.maven.plugins</groupId >
597598 <artifactId >maven-surefire-plugin</artifactId >
598599 <version >${surefire.version} </version >
600+ <configuration >
601+ <systemPropertyVariables >
602+ <logback .configurationFile>${project.rootdir} /logback.xml</logback .configurationFile>
603+ </systemPropertyVariables >
604+ </configuration >
599605 </plugin >
600606 <!-- phase: verify -->
601607 <plugin >
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments