necouchman commented on a change in pull request #546:
URL: https://github.com/apache/guacamole-client/pull/546#discussion_r513709095



##########
File path: 
guacamole/src/main/java/org/apache/guacamole/rest/connection/ConnectionResource.java
##########
@@ -150,18 +153,26 @@ public ConnectionResource(@Assisted UserContext 
userContext,
      * @throws GuacamoleException
      *     If an error occurs while retrieving the connection history.
      */
-    @GET
+    @SuppressWarnings("deprecation")
     @Path("history")
-    public List<APIConnectionRecord> getConnectionHistory()
+    public ConnectionHistoryResource getConnectionHistory()
             throws GuacamoleException {
 
-        // Retrieve the requested connection's history
-        List<APIConnectionRecord> apiRecords = new 
ArrayList<APIConnectionRecord>();
-        for (ConnectionRecord record : connection.getHistory())
-            apiRecords.add(new APIConnectionRecord(record));
-
-        // Return the converted history
-        return apiRecords;
+        try {
+            return new 
ConnectionHistoryResource(connection.getConnectionHistory());
+        }
+        catch (GuacamoleUnsupportedException e) {
+            try {
+                List<ConnectionRecord> history = Collections.emptyList();
+                for (ConnectionRecord record : connection.getHistory()) {
+                    history.add(record);
+                }
+                return new ConnectionHistoryResource(new 
SimpleActivityRecordSet<>(history));
+            }
+            catch (GuacamoleUnsupportedException ex) {
+                return new ConnectionHistoryResource(new 
SimpleActivityRecordSet<>());
+            }
+        }

Review comment:
       This is the area that I'm talking about in terms of the conversion.  So, 
what I initially tried to do was:
   ```
   try {
       return new ConnectionHistoryResource(connection.getConnectionHistory());
   }
   catch (GuacamoleUnsupportedException e) {
       try {
           return new ConnectionHistoryResource(new 
SimpleActivityRecordSet<ConnectionRecord>(connection.getHistory()));
       }
       catch (GuacamoleUnsupportedException ex) {
           return new ConnectionHistoryResource(new 
SimpleActivityRecordSet<>());
       }
   }
   ```
   However, when I do that, I get a compile error:
   
       incompatible types: List<CAP#1> cannot be converted to 
List<ConnectionRecord>
   
   This appears to be because the return type of `getHistory()` is `List<? 
extends ConnectionRecord>` whereas the input type of 
`SimpleActivityRecordSet()` is `ActivityRecord`.  For some reason that `? 
extends` causes it a bunch of heartache.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to