ptupitsyn commented on a change in pull request #524:
URL: https://github.com/apache/ignite-3/pull/524#discussion_r775353705



##########
File path: 
modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientResource.java
##########
@@ -17,20 +17,45 @@
 
 package org.apache.ignite.client.handler;
 
+import org.apache.ignite.lang.IgniteException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
 /**
  * Client resource holder.
  */
-public interface ClientResource {
+public class ClientResource {
+    /** Object. */
+    private final Object obj;
+
+    /** Release delegate. */
+    private final @Nullable Runnable releaseRunnable;
+
+    public ClientResource(@NotNull Object obj, @Nullable Runnable 
releaseRunnable) {
+        this.obj = obj;
+        this.releaseRunnable = releaseRunnable;
+    }
+
     /**
      * Gets the underlying object.
      *
      * @param <T> Object type.
      * @return Object.
      */
-    <T> T get();
+    public <T> T get(Class<T> type) {
+        if (!type.isInstance(obj)) {
+            throw new IgniteException("Incorrect resource type. Expected " + 
type.getName() + ", but got " + obj.getClass().getName());

Review comment:
       Due to Java type erasure, `T` is replaced with `Object` at compile time, 
so there is no type information at run time.




-- 
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.

To unsubscribe, e-mail: [email protected]

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


Reply via email to