Remove checked InterruptedException from dispatch method of ResponseDispatcher #35

Closed
opened 2026-04-01 12:37:52 +02:00 by lars.winzer · 5 comments
lars.winzer commented 2026-04-01 12:37:52 +02:00 (Migrated from git.scicore.unibas.ch)

Feature Request

Summary

The dispatch Method of the ResponseDispatcher should no longer have checked Exceptions.

Required workarround

As the exception is checked, every occurence needs to handle it, leading to duplicated code and the fact that e.g. the CommandHandler has nothing to do with the thread lifecycle.

Description

The current implementation is

public void dispatch(Response response) throws InterruptedException {
    PrimitiveResponse primitiveResponse = ResponseEncoder.encode(response);
    Session session = sessionManager.getSessionById(response.getSessionId());
    session.getResponseQueue().put(primitiveResponse);
}

with the change the InterruptedException is no longer checked.

public void dispatch(Response response) {
    PrimitiveResponse primitiveResponse = ResponseEncoder.encode(response);
    Session session = sessionManager.getSessionById(response.getSessionId());
    try {
        session.getResponseQueue().put(primitiveResponse);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new ResponseDispatchException("Interrupted while dispatching response", e);
    }
}

Checklist

  • I have described the function in detail
  • I searched docs for alternative implementations matching my needs
  • I added relevant labels
## Feature Request <!--The reccommended type is: Task--> ### Summary The dispatch Method of the ResponseDispatcher should no longer have checked Exceptions. ### Required workarround As the exception is checked, every occurence needs to handle it, leading to duplicated code and the fact that e.g. the CommandHandler has nothing to do with the thread lifecycle. ### Description The current implementation is ```java public void dispatch(Response response) throws InterruptedException { PrimitiveResponse primitiveResponse = ResponseEncoder.encode(response); Session session = sessionManager.getSessionById(response.getSessionId()); session.getResponseQueue().put(primitiveResponse); } ``` with the change the InterruptedException is no longer checked. ```java public void dispatch(Response response) { PrimitiveResponse primitiveResponse = ResponseEncoder.encode(response); Session session = sessionManager.getSessionById(response.getSessionId()); try { session.getResponseQueue().put(primitiveResponse); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ResponseDispatchException("Interrupted while dispatching response", e); } } ``` ### Checklist - [x] I have described the function in detail - [x] ~~I searched docs for alternative implementations matching my needs~~ - [x] I added relevant labels
lars.winzer commented 2026-04-01 12:38:06 +02:00 (Migrated from git.scicore.unibas.ch)

changed the description

changed the description
lars.winzer commented 2026-04-01 12:38:24 +02:00 (Migrated from git.scicore.unibas.ch)

assigned to @lars.winzer

assigned to @lars.winzer
lars.winzer commented 2026-04-01 12:40:05 +02:00 (Migrated from git.scicore.unibas.ch)
created branch [`feat/35-make-dispatch-method-of-responsedispatcher-unchecked`](/cs108-fs26/Gruppe-13/-/compare/main...feat%2F35-make-dispatch-method-of-responsedispatcher-unchecked) to address this issue
lars.winzer commented 2026-04-01 12:56:40 +02:00 (Migrated from git.scicore.unibas.ch)

mentioned in merge request !67

mentioned in merge request !67
lars.winzer commented 2026-04-01 13:04:15 +02:00 (Migrated from git.scicore.unibas.ch)

mentioned in commit 20e8491cff

mentioned in commit 20e8491cffbebdb3cd490c78c1f9ebb13db4ce4e
lars.winzer (Migrated from git.scicore.unibas.ch) closed this issue 2026-04-01 13:04:15 +02:00
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: University-of-Basel-Studentprojects/Programmierprojekt#35