Browse Source

Release ByteBuf

Closes gh-9661
pull/9717/head
kevin 5 years ago committed by Josh Cummings
parent
commit
32ac31c101
No known key found for this signature in database
GPG Key ID: 49EF60DD7FF83443
  1. 10
      rsocket/src/main/java/org/springframework/security/rsocket/authentication/AuthenticationPayloadExchangeConverter.java

10
rsocket/src/main/java/org/springframework/security/rsocket/authentication/AuthenticationPayloadExchangeConverter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2019 the original author or authors.
* Copyright 2019-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -71,7 +71,9 @@ public class AuthenticationPayloadExchangeConverter implements PayloadExchangeAu @@ -71,7 +71,9 @@ public class AuthenticationPayloadExchangeConverter implements PayloadExchangeAu
if (authenticationMetadata == null) {
return null;
}
ByteBuf rawAuthentication = ByteBufAllocator.DEFAULT.buffer().writeBytes(authenticationMetadata);
ByteBuf rawAuthentication = ByteBufAllocator.DEFAULT.buffer();
try {
rawAuthentication.writeBytes(authenticationMetadata);
if (!AuthMetadataCodec.isWellKnownAuthType(rawAuthentication)) {
return null;
}
@ -84,6 +86,10 @@ public class AuthenticationPayloadExchangeConverter implements PayloadExchangeAu @@ -84,6 +86,10 @@ public class AuthenticationPayloadExchangeConverter implements PayloadExchangeAu
}
throw new IllegalArgumentException("Unknown Mime Type " + wellKnownAuthType);
}
finally {
rawAuthentication.release();
}
}
private Authentication simple(ByteBuf rawAuthentication) {
ByteBuf rawUsername = AuthMetadataCodec.readUsername(rawAuthentication);

Loading…
Cancel
Save