Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of code where ParserLocker is used. #5

Open
niport opened this issue Aug 25, 2018 · 0 comments
Open

Refactoring of code where ParserLocker is used. #5

niport opened this issue Aug 25, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@niport
Copy link
Owner

niport commented Aug 25, 2018

Currently the following code pattern is used several times into the FreescaleProxy class:

	ParserLocker lock = new ParserLocker();
		lock.setType(TypeMessage.PERMIT_JOIN);
		Status status = new Status();

		getListLocker().add(lock);

		sendData(frame);

		if (lock.getStatus().getCode() == ParserLocker.INVALID_ID)
			lock.getObjectLocker().poll(timeout, TimeUnit.MILLISECONDS);

		status = lock.getStatus();

		if (getListLocker().contains(lock)) {
			getListLocker().remove(lock);
		}

		if (status.getCode() == ParserLocker.INVALID_ID)
			throw new GatewayException("Timeout expired in Permit Join");
		else {
			if (status.getCode() != 0)
				throw new GatewayException(
						"Error on ZDP-Mgmt_Permit_Join.Request. Status code:" + status.getCode() + " Status Message: " + status.getMessage());
		}

It would be better to refactor the similar code in a method.

@niport niport added the enhancement New feature or request label Aug 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant