mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[wpinet] Add mDNS discovery tests and fix mDNS JNI bugs (#8682)
In https://github.com/wpilibsuite/allwpilib/issues/8681 we discovered that multicast service types need to be valid (end with _tcp or _udp), or else errors are silently swallowed. Let's make our C++ unit test use a valid name and also check that it works. I think if we should/shouldn't do this is up for debate still. I also discovered two bugs in the JNI code that lead to incorrect results being returned - Return array index was always 0 - Use of JLocal for the return value seems to mean that the array will always be NULL in java
This commit is contained in:
@@ -330,9 +330,10 @@ Java_org_wpilib_net_WPINetJNI_getMulticastServiceResolverData
|
||||
return serviceDataEmptyArray;
|
||||
}
|
||||
|
||||
JLocal<jobjectArray> returnData{
|
||||
env, env->NewObjectArray(allData.size(), serviceDataCls, nullptr)};
|
||||
jobjectArray returnData =
|
||||
env->NewObjectArray(allData.size(), serviceDataCls, nullptr);
|
||||
|
||||
size_t index = 0;
|
||||
for (auto&& data : allData) {
|
||||
JLocal<jstring> serviceName{env, MakeJString(env, data.serviceName)};
|
||||
JLocal<jstring> hostName{env, MakeJString(env, data.hostName)};
|
||||
@@ -340,7 +341,6 @@ Java_org_wpilib_net_WPINetJNI_getMulticastServiceResolverData
|
||||
wpi::util::SmallVector<std::string_view, 8> keysRef;
|
||||
wpi::util::SmallVector<std::string_view, 8> valuesRef;
|
||||
|
||||
size_t index = 0;
|
||||
for (auto&& txt : data.txt) {
|
||||
keysRef.emplace_back(txt.first);
|
||||
valuesRef.emplace_back(txt.second);
|
||||
|
||||
Reference in New Issue
Block a user