diff --git a/.github/workflows/_check_coverage.yml b/.github/workflows/_check_coverage.yml index ad06afd6c6df..561c7759db7d 100644 --- a/.github/workflows/_check_coverage.yml +++ b/.github/workflows/_check_coverage.yml @@ -38,6 +38,7 @@ jobs: ERROR error: Error: + lower than limit rbe: true request: ${{ inputs.request }} target: ${{ matrix.target }} diff --git a/bazel/com_google_protoconverter.patch b/bazel/com_google_protoconverter.patch index f17de244d2d7..cb80e7248c52 100644 --- a/bazel/com_google_protoconverter.patch +++ b/bazel/com_google_protoconverter.patch @@ -1,11 +1,2220 @@ ---- a/src/google/protobuf/util/converter/port_def.inc 2024-01-04 20:39:52.910353189 +0000 -+++ b/src/google/protobuf/util/converter/port_def.inc 2024-01-04 20:39:02.134416756 +0000 -@@ -415,7 +415,7 @@ +diff --git a/src/google/protobuf/stubs/BUILD.bazel b/src/google/protobuf/stubs/BUILD.bazel +index a7b8c82..4f66827 100644 +--- a/src/google/protobuf/stubs/BUILD.bazel ++++ b/src/google/protobuf/stubs/BUILD.bazel +@@ -27,13 +27,11 @@ cc_library( + name = "lite", + srcs = [ + "bytestream.cc", +- "common.cc", + "strutil.cc", + ], + hdrs = [ + "bytestream.h", + "callback.h", +- "common.h", + "platform_macros.h", + "port.h", + "status_macros.h", +@@ -43,7 +41,7 @@ cc_library( + include_prefix = "google/protobuf/stubs", + linkopts = LINK_OPTS, + deps = [ +- "//src/google/protobuf/util/converter:port_def", ++ "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/status", +@@ -62,14 +60,12 @@ cc_library( + include_prefix = "google/protobuf/stubs", + textual_hdrs = [ + "callback.h", +- "common.h", + "platform_macros.h", + "port.h", + "status_macros.h", + ], + deps = [ + ":lite", +- "//src/google/protobuf/util/converter:port_def", + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", +@@ -80,7 +76,6 @@ cc_test( + name = "stubs_test", + srcs = [ + "bytestream_unittest.cc", +- "common_unittest.cc", + "strutil_unittest.cc", + ], + copts = COPTS + select({ +diff --git a/src/google/protobuf/stubs/bytestream.h b/src/google/protobuf/stubs/bytestream.h +index 9d08463..e3372cb 100644 +--- a/src/google/protobuf/stubs/bytestream.h ++++ b/src/google/protobuf/stubs/bytestream.h +@@ -43,10 +43,6 @@ + #include "absl/log/absl_check.h" + #include "absl/log/absl_log.h" + #include "absl/strings/string_view.h" +-#include "google/protobuf/stubs/common.h" +- +-// Must be last. +-#include "google/protobuf/util/converter/port_def.inc" // NOLINT - // The minimum library version which works with the current version of the - // headers. --#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 4023000 -+#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 4025000 + class CordByteSink; - #ifdef PROTOBUF_RTTI - #error PROTOBUF_RTTI was previously defined +@@ -65,7 +61,7 @@ namespace strings { + // sink->Append(my_data.data(), my_data.size()); + // sink->Flush(); + // +-class PROTOBUF_EXPORT ByteSink { ++class ByteSink { + public: + ByteSink() {} + ByteSink(const ByteSink&) = delete; +@@ -93,7 +89,7 @@ class PROTOBUF_EXPORT ByteSink { + // source->Skip(data.length()); + // } + // +-class PROTOBUF_EXPORT ByteSource { ++class ByteSource { + public: + ByteSource() {} + ByteSource(const ByteSource&) = delete; +@@ -149,7 +145,7 @@ class PROTOBUF_EXPORT ByteSource { + // sink.Append("hi", 2); // OK + // sink.Append(data, 100); // WOOPS! Overflows buf[10]. + // +-class PROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink { ++class UncheckedArrayByteSink : public ByteSink { + public: + UncheckedArrayByteSink(const UncheckedArrayByteSink&) = delete; + UncheckedArrayByteSink& operator=(const UncheckedArrayByteSink&) = delete; +@@ -178,7 +174,7 @@ class PROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink { + // sink.Append("hi", 2); // OK + // sink.Append(data, 100); // Will only write 8 more bytes + // +-class PROTOBUF_EXPORT CheckedArrayByteSink : public ByteSink { ++class CheckedArrayByteSink : public ByteSink { + public: + CheckedArrayByteSink(char* outbuf, size_t capacity); + CheckedArrayByteSink(const CheckedArrayByteSink&) = delete; +@@ -215,7 +211,7 @@ class PROTOBUF_EXPORT CheckedArrayByteSink : public ByteSink { + // const char* buf = sink.GetBuffer(); // Ownership transferred + // delete[] buf; + // +-class PROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink { ++class GrowingArrayByteSink : public strings::ByteSink { + public: + explicit GrowingArrayByteSink(size_t estimated_size); + GrowingArrayByteSink(const GrowingArrayByteSink&) = delete; +@@ -246,7 +242,7 @@ class PROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink { + // sink.Append("World", 5); + // assert(dest == "Hello World"); + // +-class PROTOBUF_EXPORT StringByteSink : public ByteSink { ++class StringByteSink : public ByteSink { + public: + explicit StringByteSink(std::string* dest) : dest_(dest) {} + StringByteSink(const StringByteSink&) = delete; +@@ -264,7 +260,7 @@ class PROTOBUF_EXPORT StringByteSink : public ByteSink { + // NullByteSink sink; + // sink.Append(data, data.size()); // All data ignored. + // +-class PROTOBUF_EXPORT NullByteSink : public ByteSink { ++class NullByteSink : public ByteSink { + public: + NullByteSink() {} + NullByteSink(const NullByteSink&) = delete; +@@ -285,7 +281,7 @@ class PROTOBUF_EXPORT NullByteSink : public ByteSink { + // assert(source.Available() == 5); + // assert(source.Peek() == "Hello"); + // +-class PROTOBUF_EXPORT ArrayByteSource : public ByteSource { ++class ArrayByteSource : public ByteSource { + public: + explicit ArrayByteSource(absl::string_view s) : input_(s) {} + ArrayByteSource(const ArrayByteSource&) = delete; +@@ -317,7 +313,7 @@ class PROTOBUF_EXPORT ArrayByteSource : public ByteSource { + // assert(limit.Available() == 5); + // assert(limit.Peek() == "Hello"); + // +-class PROTOBUF_EXPORT LimitByteSource : public ByteSource { ++class LimitByteSource : public ByteSource { + public: + // Returns at most "limit" bytes from "source". + LimitByteSource(ByteSource* source, size_t limit); +@@ -339,6 +335,4 @@ class PROTOBUF_EXPORT LimitByteSource : public ByteSource { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" // NOLINT +- + #endif // GOOGLE_PROTOBUF_STUBS_BYTESTREAM_H_ +\ No newline at end of file +diff --git a/src/google/protobuf/stubs/callback.h b/src/google/protobuf/stubs/callback.h +index 112dfca..daa6901 100644 +--- a/src/google/protobuf/stubs/callback.h ++++ b/src/google/protobuf/stubs/callback.h +@@ -19,8 +19,6 @@ + + #include + +-#include "google/protobuf/util/converter/port_def.inc" +- + // =================================================================== + // emulates google3/base/callback.h + +@@ -84,7 +82,7 @@ namespace protobuf { + // std::string my_str; + // NewCallback(&Foo, my_str); // WON'T WORK: Can't use references. + // However, correctly-typed pointers will work just fine. +-class PROTOBUF_EXPORT Closure { ++class Closure { + public: + Closure() {} + Closure(const Closure&) = delete; +@@ -106,7 +104,7 @@ class ResultCallback { + }; + + template +-class PROTOBUF_EXPORT ResultCallback1 { ++class ResultCallback1 { + public: + ResultCallback1() {} + ResultCallback1(const ResultCallback1&) = delete; +@@ -117,7 +115,7 @@ class PROTOBUF_EXPORT ResultCallback1 { + }; + + template +-class PROTOBUF_EXPORT ResultCallback2 { ++class ResultCallback2 { + public: + ResultCallback2() {} + ResultCallback2(const ResultCallback2&) = delete; +@@ -129,7 +127,7 @@ class PROTOBUF_EXPORT ResultCallback2 { + + namespace internal { + +-class PROTOBUF_EXPORT FunctionClosure0 : public Closure { ++class FunctionClosure0 : public Closure { + public: + typedef void (*FunctionType)(); + +@@ -583,11 +581,9 @@ inline ResultCallback2* NewPermanentCallback( + + // A function which does nothing. Useful for creating no-op callbacks, e.g.: + // Closure* nothing = NewCallback(&DoNothing); +-void PROTOBUF_EXPORT DoNothing(); ++void DoNothing(); + + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_STUBS_CALLBACK_H_ +diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h +index ad033a1..88690fa 100644 +--- a/src/google/protobuf/stubs/port.h ++++ b/src/google/protobuf/stubs/port.h +@@ -27,9 +27,6 @@ + + #include "google/protobuf/stubs/platform_macros.h" + +-// Must be last. +-#include "google/protobuf/util/converter/port_def.inc" // NOLINT +- + #undef PROTOBUF_LITTLE_ENDIAN + #ifdef _WIN32 + // Assuming windows is always little-endian. +@@ -217,7 +214,7 @@ static inline uint64_t bswap_64(uint64_t x) { + + // =================================================================== + // from google3/util/endian/endian.h +-PROTOBUF_EXPORT uint32_t ghtonl(uint32_t x); ++uint32_t ghtonl(uint32_t x); + + class BigEndian { + public: +@@ -278,6 +275,4 @@ class BigEndian { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_STUBS_PORT_H_ +diff --git a/src/google/protobuf/stubs/status_macros.h b/src/google/protobuf/stubs/status_macros.h +index 46e65eb..5faaf5c 100644 +--- a/src/google/protobuf/stubs/status_macros.h ++++ b/src/google/protobuf/stubs/status_macros.h +@@ -19,12 +19,9 @@ + #ifndef GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_ + #define GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_ + ++#include "absl/base/optimization.h" + #include "absl/status/status.h" + #include "absl/status/statusor.h" +-#include "google/protobuf/stubs/common.h" +- +-// Needs to be last. +-#include "google/protobuf/util/converter/port_def.inc" // NOLINT + + namespace google { + namespace protobuf { +@@ -39,7 +36,7 @@ namespace util { + do { \ + /* Using _status below to avoid capture problems if expr is "status". */ \ + const absl::Status _status = (expr); \ +- if (PROTOBUF_PREDICT_FALSE(!_status.ok())) return _status; \ ++ if (ABSL_PREDICT_FALSE(!_status.ok())) return _status; \ + } while (0) + + // Internal helper for concatenating macro values. +@@ -56,7 +53,7 @@ absl::Status DoAssignOrReturn(T& lhs, absl::StatusOr result) { + + #define ASSIGN_OR_RETURN_IMPL(status, lhs, rexpr) \ + absl::Status status = DoAssignOrReturn(lhs, (rexpr)); \ +- if (PROTOBUF_PREDICT_FALSE(!status.ok())) return status; ++ if (ABSL_PREDICT_FALSE(!status.ok())) return status; + + // Executes an expression that returns a util::StatusOr, extracting its value + // into the variable defined by lhs (or returning on error). +@@ -75,6 +72,4 @@ absl::Status DoAssignOrReturn(T& lhs, absl::StatusOr result) { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" // NOLINT +- + #endif // GOOGLE_PROTOBUF_STUBS_STATUS_H_ +diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h +index 82882f4..4d09bad 100644 +--- a/src/google/protobuf/stubs/strutil.h ++++ b/src/google/protobuf/stubs/strutil.h +@@ -17,15 +17,13 @@ + #ifndef GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ + #define GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ + +-#include +-#include +- ++#include + #include +-#include + #include + + #include "absl/strings/str_cat.h" + #include "absl/strings/str_join.h" ++#include "google/protobuf/stubs/port.h" + + namespace google { + namespace protobuf { +@@ -138,10 +136,9 @@ inline std::string StripSuffixString(const std::string& str, + // StripWhitespace + // Removes whitespaces from both ends of the given string. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT void ReplaceCharacters(std::string* s, const char* remove, +- char replacewith); ++void ReplaceCharacters(std::string* s, const char* remove, char replacewith); + +-PROTOBUF_EXPORT void StripWhitespace(std::string* s); ++void StripWhitespace(std::string* s); + + // ---------------------------------------------------------------------- + // LowerString() +@@ -185,10 +182,8 @@ inline std::string ToUpper(const std::string& s) { + // happened or not. + // ---------------------------------------------------------------------- + +-PROTOBUF_EXPORT std::string StringReplace(const std::string& s, +- const std::string& oldsub, +- const std::string& newsub, +- bool replace_all); ++std::string StringReplace(const std::string& s, const std::string& oldsub, ++ const std::string& newsub, bool replace_all); + + // ---------------------------------------------------------------------- + // SplitStringUsing() +@@ -196,8 +191,8 @@ PROTOBUF_EXPORT std::string StringReplace(const std::string& s, + // to 'result'. If there are consecutive delimiters, this function skips + // over all of them. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT void SplitStringUsing(absl::string_view full, const char* delim, +- std::vector* res); ++void SplitStringUsing(absl::string_view full, const char* delim, ++ std::vector* res); + + // Split a string using one or more byte delimiters, presented + // as a nul-terminated c string. Append the components to 'result'. +@@ -207,9 +202,8 @@ PROTOBUF_EXPORT void SplitStringUsing(absl::string_view full, const char* delim, + // + // If "full" is the empty string, yields an empty string as the only value. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT void SplitStringAllowEmpty(absl::string_view full, +- const char* delim, +- std::vector* result); ++void SplitStringAllowEmpty(absl::string_view full, const char* delim, ++ std::vector* result); + + // ---------------------------------------------------------------------- + // Split() +@@ -234,8 +228,8 @@ inline std::vector Split(absl::string_view full, const char* delim, + // another takes a pointer to the target string. In the latter case the + // target string is cleared and overwritten. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT void JoinStrings(const std::vector& components, +- const char* delim, std::string* result); ++void JoinStrings(const std::vector& components, const char* delim, ++ std::string* result); + + inline std::string JoinStrings(const std::vector& components, + const char* delim) { +@@ -275,9 +269,9 @@ inline std::string JoinStrings(const std::vector& components, + // processed. + // ---------------------------------------------------------------------- + +-PROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest); +-PROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest, +- std::vector* errors); ++int UnescapeCEscapeSequences(const char* source, char* dest); ++int UnescapeCEscapeSequences(const char* source, char* dest, ++ std::vector* errors); + + // ---------------------------------------------------------------------- + // UnescapeCEscapeString() +@@ -294,12 +288,10 @@ PROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest, + // the third call, the new string is returned. + // ---------------------------------------------------------------------- + +-PROTOBUF_EXPORT int UnescapeCEscapeString(const std::string& src, +- std::string* dest); +-PROTOBUF_EXPORT int UnescapeCEscapeString(const std::string& src, +- std::string* dest, +- std::vector* errors); +-PROTOBUF_EXPORT std::string UnescapeCEscapeString(const std::string& src); ++int UnescapeCEscapeString(const std::string& src, std::string* dest); ++int UnescapeCEscapeString(const std::string& src, std::string* dest, ++ std::vector* errors); ++std::string UnescapeCEscapeString(const std::string& src); + + // ---------------------------------------------------------------------- + // CEscape() +@@ -308,21 +300,21 @@ PROTOBUF_EXPORT std::string UnescapeCEscapeString(const std::string& src); + // + // Escaped chars: \n, \r, \t, ", ', \, and !isprint(). + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT std::string CEscape(const std::string& src); ++std::string CEscape(const std::string& src); + + // ---------------------------------------------------------------------- + // CEscapeAndAppend() + // Escapes 'src' using C-style escape sequences, and appends the escaped + // string to 'dest'. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT void CEscapeAndAppend(absl::string_view src, std::string* dest); ++void CEscapeAndAppend(absl::string_view src, std::string* dest); + + namespace strings { + // Like CEscape() but does not escape bytes with the upper bit set. +-PROTOBUF_EXPORT std::string Utf8SafeCEscape(const std::string& src); ++std::string Utf8SafeCEscape(const std::string& src); + + // Like CEscape() but uses hex (\x) escapes instead of octals. +-PROTOBUF_EXPORT std::string CHexEscape(const std::string& src); ++std::string CHexEscape(const std::string& src); + } // namespace strings + + // ---------------------------------------------------------------------- +@@ -335,10 +327,8 @@ PROTOBUF_EXPORT std::string CHexEscape(const std::string& src); + // platforms, so using these is safer, from the point of view of + // overflow behavior, than using the standard libc functions. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT int32_t strto32_adaptor(const char* nptr, char** endptr, +- int base); +-PROTOBUF_EXPORT uint32_t strtou32_adaptor(const char* nptr, char** endptr, +- int base); ++int32_t strto32_adaptor(const char* nptr, char** endptr, int base); ++uint32_t strtou32_adaptor(const char* nptr, char** endptr, int base); + + inline int32_t strto32(const char* nptr, char** endptr, int base) { + if (sizeof(int32_t) == sizeof(long)) +@@ -377,10 +367,10 @@ inline uint64_t strtou64(const char* nptr, char** endptr, int base) { + // safe_strtof() + // safe_strtod() + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT bool safe_strtob(absl::string_view str, bool* value); ++bool safe_strtob(absl::string_view str, bool* value); + +-PROTOBUF_EXPORT bool safe_strto32(const std::string& str, int32_t* value); +-PROTOBUF_EXPORT bool safe_strtou32(const std::string& str, uint32_t* value); ++bool safe_strto32(const std::string& str, int32_t* value); ++bool safe_strtou32(const std::string& str, uint32_t* value); + inline bool safe_strto32(const char* str, int32_t* value) { + return safe_strto32(std::string(str), value); + } +@@ -394,8 +384,8 @@ inline bool safe_strtou32(absl::string_view str, uint32_t* value) { + return safe_strtou32(std::string(str), value); + } + +-PROTOBUF_EXPORT bool safe_strto64(const std::string& str, int64_t* value); +-PROTOBUF_EXPORT bool safe_strtou64(const std::string& str, uint64_t* value); ++bool safe_strto64(const std::string& str, int64_t* value); ++bool safe_strtou64(const std::string& str, uint64_t* value); + inline bool safe_strto64(const char* str, int64_t* value) { + return safe_strto64(std::string(str), value); + } +@@ -409,8 +399,8 @@ inline bool safe_strtou64(absl::string_view str, uint64_t* value) { + return safe_strtou64(std::string(str), value); + } + +-PROTOBUF_EXPORT bool safe_strtof(const char* str, float* value); +-PROTOBUF_EXPORT bool safe_strtod(const char* str, double* value); ++bool safe_strtof(const char* str, float* value); ++bool safe_strtod(const char* str, double* value); + inline bool safe_strtof(const std::string& str, float* value) { + return safe_strtof(str.c_str(), value); + } +@@ -450,13 +440,13 @@ inline bool safe_strtod(absl::string_view str, double* value) { + // DoubleToBuffer() and FloatToBuffer(). + static const int kFastToBufferSize = 32; + +-PROTOBUF_EXPORT char* FastInt32ToBuffer(int32_t i, char* buffer); +-PROTOBUF_EXPORT char* FastInt64ToBuffer(int64_t i, char* buffer); ++char* FastInt32ToBuffer(int32_t i, char* buffer); ++char* FastInt64ToBuffer(int64_t i, char* buffer); + char* FastUInt32ToBuffer(uint32_t i, char* buffer); // inline below + char* FastUInt64ToBuffer(uint64_t i, char* buffer); // inline below +-PROTOBUF_EXPORT char* FastHexToBuffer(int i, char* buffer); +-PROTOBUF_EXPORT char* FastHex64ToBuffer(uint64_t i, char* buffer); +-PROTOBUF_EXPORT char* FastHex32ToBuffer(uint32_t i, char* buffer); ++char* FastHexToBuffer(int i, char* buffer); ++char* FastHex64ToBuffer(uint64_t i, char* buffer); ++char* FastHex32ToBuffer(uint32_t i, char* buffer); + + // at least 22 bytes long + inline char* FastIntToBuffer(int i, char* buffer) { +@@ -492,10 +482,10 @@ inline char* FastULongToBuffer(unsigned long i, char* buffer) { + // terminating the string). + // ---------------------------------------------------------------------- + +-PROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32_t i, char* buffer); +-PROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32_t i, char* buffer); +-PROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64_t i, char* buffer); +-PROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64_t i, char* buffer); ++char* FastInt32ToBufferLeft(int32_t i, char* buffer); ++char* FastUInt32ToBufferLeft(uint32_t i, char* buffer); ++char* FastInt64ToBufferLeft(int64_t i, char* buffer); ++char* FastUInt64ToBufferLeft(uint64_t i, char* buffer); + + // Just define these in terms of the above. + inline char* FastUInt32ToBuffer(uint32_t i, char* buffer) { +@@ -515,12 +505,12 @@ inline std::string SimpleBtoa(bool value) { return value ? "true" : "false"; } + // + // Return value: string + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT std::string SimpleItoa(int i); +-PROTOBUF_EXPORT std::string SimpleItoa(unsigned int i); +-PROTOBUF_EXPORT std::string SimpleItoa(long i); +-PROTOBUF_EXPORT std::string SimpleItoa(unsigned long i); +-PROTOBUF_EXPORT std::string SimpleItoa(long long i); +-PROTOBUF_EXPORT std::string SimpleItoa(unsigned long long i); ++std::string SimpleItoa(int i); ++std::string SimpleItoa(unsigned int i); ++std::string SimpleItoa(long i); ++std::string SimpleItoa(unsigned long i); ++std::string SimpleItoa(long long i); ++std::string SimpleItoa(unsigned long long i); + + // ---------------------------------------------------------------------- + // SimpleDtoa() +@@ -541,11 +531,11 @@ PROTOBUF_EXPORT std::string SimpleItoa(unsigned long long i); + // + // Return value: string + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT std::string SimpleDtoa(double value); +-PROTOBUF_EXPORT std::string SimpleFtoa(float value); ++std::string SimpleDtoa(double value); ++std::string SimpleFtoa(float value); + +-PROTOBUF_EXPORT char* DoubleToBuffer(double i, char* buffer); +-PROTOBUF_EXPORT char* FloatToBuffer(float i, char* buffer); ++char* DoubleToBuffer(double i, char* buffer); ++char* FloatToBuffer(float i, char* buffer); + + // In practice, doubles should never need more than 24 bytes and floats + // should never need more than 14 (including null terminators), but we +@@ -563,7 +553,7 @@ using Hex = absl::Hex; + // ToHex() + // Return a lower-case hex string representation of the given integer. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT std::string ToHex(uint64_t num); ++std::string ToHex(uint64_t num); + + // ---------------------------------------------------------------------- + // GlobalReplaceSubstring() +@@ -572,9 +562,8 @@ PROTOBUF_EXPORT std::string ToHex(uint64_t num); + // + // NOTE: The string pieces must not overlap s. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT int GlobalReplaceSubstring(const std::string& substring, +- const std::string& replacement, +- std::string* s); ++int GlobalReplaceSubstring(const std::string& substring, ++ const std::string& replacement, std::string* s); + + // ---------------------------------------------------------------------- + // Base64Unescape() +@@ -582,7 +571,7 @@ PROTOBUF_EXPORT int GlobalReplaceSubstring(const std::string& substring, + // writes it to "dest". If src contains invalid characters, dest is cleared + // and the function returns false. Returns true on success. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT bool Base64Unescape(absl::string_view src, std::string* dest); ++bool Base64Unescape(absl::string_view src, std::string* dest); + + // ---------------------------------------------------------------------- + // WebSafeBase64Unescape() +@@ -595,18 +584,16 @@ PROTOBUF_EXPORT bool Base64Unescape(absl::string_view src, std::string* dest); + // returns false (with dest empty) if src contains invalid chars; for + // this version src and dest must be different strings. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT int WebSafeBase64Unescape(const char* src, int slen, char* dest, +- int szdest); +-PROTOBUF_EXPORT bool WebSafeBase64Unescape(absl::string_view src, +- std::string* dest); ++int WebSafeBase64Unescape(const char* src, int slen, char* dest, int szdest); ++bool WebSafeBase64Unescape(absl::string_view src, std::string* dest); + + // Return the length to use for the output buffer given to the base64 escape + // routines. Make sure to use the same value for do_padding in both. + // This function may return incorrect results if given input_len values that + // are extremely high, which should happen rarely. +-PROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len, bool do_padding); ++int CalculateBase64EscapedLen(int input_len, bool do_padding); + // Use this version when calling Base64Escape without a do_padding arg. +-PROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len); ++int CalculateBase64EscapedLen(int input_len); + + // ---------------------------------------------------------------------- + // Base64Escape() +@@ -620,24 +607,20 @@ PROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len); + // to escape them. It also has an extra parameter "do_padding", + // which when set to false will prevent padding with "=". + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT int Base64Escape(const unsigned char* src, int slen, char* dest, +- int szdest); +-PROTOBUF_EXPORT int WebSafeBase64Escape(const unsigned char* src, int slen, +- char* dest, int szdest, +- bool do_padding); ++int Base64Escape(const unsigned char* src, int slen, char* dest, int szdest); ++int WebSafeBase64Escape(const unsigned char* src, int slen, char* dest, ++ int szdest, bool do_padding); + // Encode src into dest with padding. +-PROTOBUF_EXPORT void Base64Escape(absl::string_view src, std::string* dest); ++void Base64Escape(absl::string_view src, std::string* dest); + // Encode src into dest web-safely without padding. +-PROTOBUF_EXPORT void WebSafeBase64Escape(absl::string_view src, +- std::string* dest); ++void WebSafeBase64Escape(absl::string_view src, std::string* dest); + // Encode src into dest web-safely with padding. +-PROTOBUF_EXPORT void WebSafeBase64EscapeWithPadding(absl::string_view src, +- std::string* dest); ++void WebSafeBase64EscapeWithPadding(absl::string_view src, std::string* dest); + +-PROTOBUF_EXPORT void Base64Escape(const unsigned char* src, int szsrc, +- std::string* dest, bool do_padding); +-PROTOBUF_EXPORT void WebSafeBase64Escape(const unsigned char* src, int szsrc, +- std::string* dest, bool do_padding); ++void Base64Escape(const unsigned char* src, int szsrc, std::string* dest, ++ bool do_padding); ++void WebSafeBase64Escape(const unsigned char* src, int szsrc, std::string* dest, ++ bool do_padding); + + inline bool IsValidCodePoint(uint32_t code_point) { + return code_point < 0xD800 || +@@ -651,13 +634,13 @@ static const int UTFmax = 4; + // in any external dependencies. The output buffer must be as least 4 bytes + // large. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT int EncodeAsUTF8Char(uint32_t code_point, char* output); ++int EncodeAsUTF8Char(uint32_t code_point, char* output); + + // ---------------------------------------------------------------------- + // UTF8FirstLetterNumBytes() + // Length of the first UTF-8 character. + // ---------------------------------------------------------------------- +-PROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char* src, int len); ++int UTF8FirstLetterNumBytes(const char* src, int len); + + // From google3/third_party/absl/strings/escaping.h + +@@ -693,13 +676,11 @@ PROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char* src, int len); + // + // (1) determines the presence of LF (first one is ok) + // (2) if yes, removes any CR, else convert every CR to LF +-PROTOBUF_EXPORT void CleanStringLineEndings(const std::string& src, +- std::string* dst, +- bool auto_end_last_line); ++void CleanStringLineEndings(const std::string& src, std::string* dst, ++ bool auto_end_last_line); + + // Same as above, but transforms the argument in place. +-PROTOBUF_EXPORT void CleanStringLineEndings(std::string* str, +- bool auto_end_last_line); ++void CleanStringLineEndings(std::string* str, bool auto_end_last_line); + + namespace strings { + inline bool EndsWith(absl::string_view text, absl::string_view suffix) { +@@ -720,6 +701,5 @@ double NoLocaleStrtod(const char* str, char** endptr); + } // namespace protobuf + } // namespace google + +-#include + + #endif // GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ +\ No newline at end of file +diff --git a/src/google/protobuf/util/converter/BUILD.bazel b/src/google/protobuf/util/converter/BUILD.bazel +index bff9574..bcfa7ea 100644 +--- a/src/google/protobuf/util/converter/BUILD.bazel ++++ b/src/google/protobuf/util/converter/BUILD.bazel +@@ -28,8 +28,7 @@ cc_library( + hdrs = ["constants.h"], + strip_include_prefix = "/src", + deps = [ +- "//src/google/protobuf/stubs", +- "//src/google/protobuf/util/converter:port_def", ++ "//src/google/protobuf/util/converter:port", + ], + ) + +@@ -42,19 +41,16 @@ cc_library( + deps = [ + ":constants", + ":utility", +- "//src/google/protobuf/stubs", +- "//src/google/protobuf/util/converter:port_def", ++ "//src/google/protobuf/util/converter:port", + "@com_google_absl//absl/strings", + "@com_google_protobuf//:protobuf", + ], + ) + + cc_library( +- name = "port_def", ++ name = "port", + hdrs = [ + "port.h", +- "port_def.inc", +- "port_undef.inc", + ], + strip_include_prefix = "/src", + visibility = [ +@@ -78,7 +74,7 @@ cc_library( + ":type_info", + ":utility", + "//src/google/protobuf/stubs", +- "//src/google/protobuf/util/converter:port_def", ++ "//src/google/protobuf/util/converter:port", + ], + ) + +@@ -133,7 +129,7 @@ cc_library( + ":object_writer", + ":utility", + "//src/google/protobuf/stubs", +- "//src/google/protobuf/util/converter:port_def", ++ "//src/google/protobuf/util/converter:port", + "@com_google_absl//absl/status", + "@com_google_absl//absl/strings", + "@com_google_protobuf//:protobuf", +diff --git a/src/google/protobuf/util/converter/constants.h b/src/google/protobuf/util/converter/constants.h +index ff75f92..3843aa2 100644 +--- a/src/google/protobuf/util/converter/constants.h ++++ b/src/google/protobuf/util/converter/constants.h +@@ -19,8 +19,6 @@ + + #include + +-#include "google/protobuf/stubs/common.h" +- + // This file contains constants used by //net/proto2/util/converter. + + namespace google { +diff --git a/src/google/protobuf/util/converter/datapiece.cc b/src/google/protobuf/util/converter/datapiece.cc +index 3acd35d..c7c12ef 100644 +--- a/src/google/protobuf/util/converter/datapiece.cc ++++ b/src/google/protobuf/util/converter/datapiece.cc +@@ -18,18 +18,17 @@ + #include + #include + +-#include "google/protobuf/struct.pb.h" +-#include "google/protobuf/type.pb.h" +-#include "google/protobuf/descriptor.h" + #include "absl/status/status.h" + #include "absl/strings/ascii.h" + #include "absl/strings/cord.h" + #include "absl/strings/escaping.h" ++#include "absl/strings/match.h" + #include "absl/strings/str_cat.h" +-#include "google/protobuf/util/converter/utility.h" +-#include "google/protobuf/stubs/strutil.h" ++#include "google/protobuf/descriptor.h" ++#include "google/protobuf/struct.pb.h" + #include "google/protobuf/stubs/strutil.h" +-#include "absl/strings/match.h" ++#include "google/protobuf/type.pb.h" ++#include "google/protobuf/util/converter/utility.h" + + namespace google { + namespace protobuf { +diff --git a/src/google/protobuf/util/converter/datapiece.h b/src/google/protobuf/util/converter/datapiece.h +index 68b6b0e..fc25a7a 100644 +--- a/src/google/protobuf/util/converter/datapiece.h ++++ b/src/google/protobuf/util/converter/datapiece.h +@@ -20,15 +20,10 @@ + #include + #include + +-#include "google/protobuf/stubs/common.h" +-#include "google/protobuf/type.pb.h" + #include "absl/log/absl_log.h" +- + #include "absl/status/statusor.h" + #include "absl/strings/string_view.h" +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" ++#include "google/protobuf/type.pb.h" + + namespace google { + namespace protobuf { +@@ -46,7 +41,7 @@ class ProtoWriter; + // storage for the actual string or Cord, so it is the user's responsibility to + // guarantee that the underlying storage is still valid when the DataPiece is + // accessed. +-class PROTOBUF_EXPORT DataPiece { ++class DataPiece { + public: + // Identifies data type of the value. + // These are the types supported by DataPiece. +@@ -107,8 +102,7 @@ class PROTOBUF_EXPORT DataPiece { + + static DataPiece NullData() { return DataPiece(TYPE_NULL, 0); } + +- virtual ~DataPiece() { +- } ++ virtual ~DataPiece() {} + + // Accessors + Type type() const { return type_; } +@@ -120,7 +114,6 @@ class PROTOBUF_EXPORT DataPiece { + return str_; + } + +- + // Parses, casts or converts the value stored in the DataPiece into an int32. + absl::StatusOr ToInt32() const; + +@@ -206,6 +199,4 @@ class PROTOBUF_EXPORT DataPiece { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H_ +diff --git a/src/google/protobuf/util/converter/default_value_objectwriter.h b/src/google/protobuf/util/converter/default_value_objectwriter.h +index 0b253c8..4538fc7 100644 +--- a/src/google/protobuf/util/converter/default_value_objectwriter.h ++++ b/src/google/protobuf/util/converter/default_value_objectwriter.h +@@ -31,9 +31,6 @@ + #include "google/protobuf/util/converter/utility.h" + #include "google/protobuf/util/type_resolver.h" + +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { +@@ -45,7 +42,7 @@ namespace converter { + // ObjectWriter when EndObject() is called on the root object. It also writes + // out all non-repeated primitive fields that haven't been explicitly rendered + // with their default values (0 for numbers, "" for strings, etc). +-class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { ++class DefaultValueObjectWriter : public ObjectWriter { + public: + // A Callback function to check whether a field needs to be scrubbed. + // +@@ -134,7 +131,7 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { + + // "Node" represents a node in the tree that holds the input of + // DefaultValueObjectWriter. +- class PROTOBUF_EXPORT Node { ++ class Node { + public: + Node(const std::string& name, const google::protobuf::Type* type, + NodeKind kind, const DataPiece& data, bool is_placeholder, +@@ -312,6 +309,4 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H_ +diff --git a/src/google/protobuf/util/converter/error_listener.h b/src/google/protobuf/util/converter/error_listener.h +index 2d671a5..04c4df6 100644 +--- a/src/google/protobuf/util/converter/error_listener.h ++++ b/src/google/protobuf/util/converter/error_listener.h +@@ -22,21 +22,17 @@ + #include + #include + +-#include "google/protobuf/stubs/callback.h" +-#include "google/protobuf/stubs/common.h" + #include "absl/strings/string_view.h" ++#include "google/protobuf/stubs/callback.h" + #include "google/protobuf/util/converter/location_tracker.h" + +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { + namespace converter { + + // Interface for error listener. +-class PROTOBUF_EXPORT ErrorListener { ++class ErrorListener { + public: + ErrorListener(const ErrorListener&) = delete; + ErrorListener& operator=(const ErrorListener&) = delete; +@@ -61,7 +57,7 @@ class PROTOBUF_EXPORT ErrorListener { + }; + + // An error listener that ignores all errors. +-class PROTOBUF_EXPORT NoopErrorListener : public ErrorListener { ++class NoopErrorListener : public ErrorListener { + public: + NoopErrorListener() {} + NoopErrorListener(const NoopErrorListener&) = delete; +@@ -80,12 +76,9 @@ class PROTOBUF_EXPORT NoopErrorListener : public ErrorListener { + absl::string_view /* missing_name */) override {} + }; + +- + } // namespace converter + } // namespace util + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H_ +diff --git a/src/google/protobuf/util/converter/field_mask_utility.cc b/src/google/protobuf/util/converter/field_mask_utility.cc +index 03736d7..c3a8ec2 100644 +--- a/src/google/protobuf/util/converter/field_mask_utility.cc ++++ b/src/google/protobuf/util/converter/field_mask_utility.cc +@@ -17,11 +17,8 @@ + #include "absl/status/status.h" + #include "absl/strings/match.h" + #include "absl/strings/str_cat.h" +-#include "google/protobuf/util/converter/utility.h" + #include "google/protobuf/stubs/status_macros.h" +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" ++#include "google/protobuf/util/converter/utility.h" + + namespace google { + namespace protobuf { +diff --git a/src/google/protobuf/util/converter/json_objectwriter.h b/src/google/protobuf/util/converter/json_objectwriter.h +index e3caf4d..4069682 100644 +--- a/src/google/protobuf/util/converter/json_objectwriter.h ++++ b/src/google/protobuf/util/converter/json_objectwriter.h +@@ -21,20 +21,15 @@ + #include + #include + ++#include "google/protobuf/io/coded_stream.h" + #include "google/protobuf/stubs/bytestream.h" + #include "google/protobuf/util/converter/structured_objectwriter.h" +-#include "google/protobuf/io/coded_stream.h" +- +-// clang-format off +-#include "google/protobuf/util/converter/port_def.inc" +-// clang-format on + + namespace google { + namespace protobuf { + namespace util { + namespace converter { + +- + // An ObjectWriter implementation that outputs JSON. This ObjectWriter + // supports writing a compact form or a pretty printed form. + // +@@ -74,7 +69,7 @@ namespace converter { + // uint64 would lose precision if rendered as numbers. + // + // JsonObjectWriter is thread-unsafe. +-class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { ++class JsonObjectWriter : public StructuredObjectWriter { + public: + JsonObjectWriter(absl::string_view indent_string, io::CodedOutputStream* out) + : element_(new Element(/*parent=*/nullptr, /*is_json_object=*/false)), +@@ -127,7 +122,7 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { + } + + protected: +- class PROTOBUF_EXPORT Element : public BaseElement { ++ class Element : public BaseElement { + public: + Element(Element* parent, bool is_json_object) + : BaseElement(parent), +@@ -158,7 +153,7 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { + Element* element() override { return element_.get(); } + + private: +- class PROTOBUF_EXPORT ByteSinkWrapper : public strings::ByteSink { ++ class ByteSinkWrapper : public strings::ByteSink { + public: + explicit ByteSinkWrapper(io::CodedOutputStream* stream) : stream_(stream) {} + ByteSinkWrapper(const ByteSinkWrapper&) = delete; +@@ -260,6 +255,4 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H_ +diff --git a/src/google/protobuf/util/converter/json_stream_parser.h b/src/google/protobuf/util/converter/json_stream_parser.h +index ed30e3a..3cc40a4 100644 +--- a/src/google/protobuf/util/converter/json_stream_parser.h ++++ b/src/google/protobuf/util/converter/json_stream_parser.h +@@ -21,22 +21,15 @@ + #include + #include + +-#include "google/protobuf/stubs/common.h" + #include "absl/status/status.h" +-#include "absl/types/optional.h" +- + #include "absl/strings/string_view.h" +- +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" ++#include "absl/types/optional.h" + + namespace google { + namespace protobuf { + namespace util { + namespace converter { + +- + class ObjectWriter; + + // A JSON parser that can parse a stream of JSON chunks rather than needing the +@@ -59,7 +52,7 @@ class ObjectWriter; + // + // This parser is thread-compatible as long as only one thread is calling a + // Parse() method at a time. +-class PROTOBUF_EXPORT JsonStreamParser { ++class JsonStreamParser { + public: + // Creates a JsonStreamParser that will write to the given ObjectWriter. + explicit JsonStreamParser(ObjectWriter* ow); +@@ -74,14 +67,12 @@ class PROTOBUF_EXPORT JsonStreamParser { + // string snippet of the error with type_url kParseErrorSnippetUrl. + absl::Status Parse(absl::string_view json); + +- + // Finish parsing the JSON string. If the returned status is non-ok, the + // status might contain a payload ParseErrorType with type_url + // kParseErrorTypeUrl and a payload containing string snippet of the error + // with type_url kParseErrorSnippetUrl. + absl::Status FinishParse(); + +- + // Sets the max recursion depth of JSON message to be deserialized. JSON + // messages over this depth will fail to be deserialized. + // Default value is 100. +@@ -331,6 +322,4 @@ class PROTOBUF_EXPORT JsonStreamParser { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H_ +diff --git a/src/google/protobuf/util/converter/legacy_json_util.cc b/src/google/protobuf/util/converter/legacy_json_util.cc +index 6f37aa5..0ea7e3c 100644 +--- a/src/google/protobuf/util/converter/legacy_json_util.cc ++++ b/src/google/protobuf/util/converter/legacy_json_util.cc +@@ -18,26 +18,22 @@ + + #include "absl/base/call_once.h" + #include "absl/status/status.h" +-#include "google/protobuf/stubs/bytestream.h" + #include "absl/strings/str_cat.h" + #include "absl/strings/string_view.h" ++#include "google/protobuf/io/coded_stream.h" ++#include "google/protobuf/io/zero_copy_sink.h" ++#include "google/protobuf/io/zero_copy_stream.h" ++#include "google/protobuf/stubs/bytestream.h" ++#include "google/protobuf/stubs/status_macros.h" + #include "google/protobuf/util/converter/default_value_objectwriter.h" + #include "google/protobuf/util/converter/error_listener.h" + #include "google/protobuf/util/converter/json_objectwriter.h" + #include "google/protobuf/util/converter/json_stream_parser.h" + #include "google/protobuf/util/converter/protostream_objectsource.h" + #include "google/protobuf/util/converter/protostream_objectwriter.h" +-#include "google/protobuf/io/coded_stream.h" +-#include "google/protobuf/io/zero_copy_sink.h" +-#include "google/protobuf/io/zero_copy_stream.h" + #include "google/protobuf/util/type_resolver.h" + #include "google/protobuf/util/type_resolver_util.h" +-#include "google/protobuf/stubs/status_macros.h" +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" + +-namespace google { + namespace protobuf { + namespace util { + using ::google::protobuf::io::zc_sink_internal::ZeroCopyStreamByteSink; +diff --git a/src/google/protobuf/util/converter/legacy_json_util.h b/src/google/protobuf/util/converter/legacy_json_util.h +index 3399da0..44c0d07 100644 +--- a/src/google/protobuf/util/converter/legacy_json_util.h ++++ b/src/google/protobuf/util/converter/legacy_json_util.h +@@ -24,9 +24,6 @@ + #include "google/protobuf/message.h" + #include "google/protobuf/util/type_resolver.h" + +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { +@@ -57,27 +54,27 @@ struct JsonPrintOptions { + + typedef JsonPrintOptions JsonOptions; + +-PROTOBUF_EXPORT absl::Status MessageToJsonString(const Message& message, +- std::string* output, +- const JsonOptions& options); ++absl::Status MessageToJsonString(const Message& message, std::string* output, ++ const JsonOptions& options); + + inline absl::Status MessageToJsonString(const Message& message, + std::string* output) { + return MessageToJsonString(message, output, JsonOptions()); + } + +-PROTOBUF_EXPORT absl::Status JsonStringToMessage( +- absl::string_view input, Message* message, const JsonParseOptions& options); ++absl::Status JsonStringToMessage(absl::string_view input, Message* message, ++ const JsonParseOptions& options); + + inline absl::Status JsonStringToMessage(absl::string_view input, + Message* message) { + return JsonStringToMessage(input, message, JsonParseOptions()); + } + +-PROTOBUF_EXPORT absl::Status BinaryToJsonStream( +- TypeResolver* resolver, const std::string& type_url, +- io::ZeroCopyInputStream* binary_input, +- io::ZeroCopyOutputStream* json_output, const JsonPrintOptions& options); ++absl::Status BinaryToJsonStream(TypeResolver* resolver, ++ const std::string& type_url, ++ io::ZeroCopyInputStream* binary_input, ++ io::ZeroCopyOutputStream* json_output, ++ const JsonPrintOptions& options); + + inline absl::Status BinaryToJsonStream(TypeResolver* resolver, + const std::string& type_url, +@@ -87,10 +84,11 @@ inline absl::Status BinaryToJsonStream(TypeResolver* resolver, + JsonPrintOptions()); + } + +-PROTOBUF_EXPORT absl::Status BinaryToJsonString( +- TypeResolver* resolver, const std::string& type_url, +- const std::string& binary_input, std::string* json_output, +- const JsonPrintOptions& options); ++absl::Status BinaryToJsonString(TypeResolver* resolver, ++ const std::string& type_url, ++ const std::string& binary_input, ++ std::string* json_output, ++ const JsonPrintOptions& options); + + inline absl::Status BinaryToJsonString(TypeResolver* resolver, + const std::string& type_url, +@@ -100,10 +98,11 @@ inline absl::Status BinaryToJsonString(TypeResolver* resolver, + JsonPrintOptions()); + } + +-PROTOBUF_EXPORT absl::Status JsonToBinaryStream( +- TypeResolver* resolver, const std::string& type_url, +- io::ZeroCopyInputStream* json_input, +- io::ZeroCopyOutputStream* binary_output, const JsonParseOptions& options); ++absl::Status JsonToBinaryStream(TypeResolver* resolver, ++ const std::string& type_url, ++ io::ZeroCopyInputStream* json_input, ++ io::ZeroCopyOutputStream* binary_output, ++ const JsonParseOptions& options); + + inline absl::Status JsonToBinaryStream( + TypeResolver* resolver, const std::string& type_url, +@@ -113,10 +112,11 @@ inline absl::Status JsonToBinaryStream( + JsonParseOptions()); + } + +-PROTOBUF_EXPORT absl::Status JsonToBinaryString( +- TypeResolver* resolver, const std::string& type_url, +- absl::string_view json_input, std::string* binary_output, +- const JsonParseOptions& options); ++absl::Status JsonToBinaryString(TypeResolver* resolver, ++ const std::string& type_url, ++ absl::string_view json_input, ++ std::string* binary_output, ++ const JsonParseOptions& options); + + inline absl::Status JsonToBinaryString(TypeResolver* resolver, + const std::string& type_url, +@@ -130,6 +130,4 @@ inline absl::Status JsonToBinaryString(TypeResolver* resolver, + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_LEGACY_UTIL_H_ +diff --git a/src/google/protobuf/util/converter/legacy_json_util_test.cc b/src/google/protobuf/util/converter/legacy_json_util_test.cc +index eda760a..c95abe9 100644 +--- a/src/google/protobuf/util/converter/legacy_json_util_test.cc ++++ b/src/google/protobuf/util/converter/legacy_json_util_test.cc +@@ -14,6 +14,9 @@ + + #include "google/protobuf/util/converter/legacy_json_util.h" + ++#include ++#include ++ + #include + #include + #include +@@ -21,29 +24,24 @@ + #include + #include + +-#include "google/protobuf/duration.pb.h" +-#include "google/protobuf/field_mask.pb.h" +-#include "google/protobuf/struct.pb.h" +-#include "google/protobuf/timestamp.pb.h" +-#include "google/protobuf/wrappers.pb.h" +-#include +-#include + #include "absl/status/status.h" + #include "absl/status/statusor.h" + #include "absl/strings/string_view.h" +-#include "google/protobuf/util/converter/testdata/maps.pb.h" + #include "google/protobuf/descriptor_database.h" ++#include "google/protobuf/duration.pb.h" + #include "google/protobuf/dynamic_message.h" ++#include "google/protobuf/field_mask.pb.h" + #include "google/protobuf/io/zero_copy_stream_impl_lite.h" ++#include "google/protobuf/struct.pb.h" ++#include "google/protobuf/stubs/status_macros.h" ++#include "google/protobuf/timestamp.pb.h" ++#include "google/protobuf/unittest.pb.h" ++#include "google/protobuf/util/converter/testdata/maps.pb.h" + #include "google/protobuf/util/json_format.pb.h" + #include "google/protobuf/util/json_format_proto3.pb.h" +-#include "google/protobuf/unittest.pb.h" + #include "google/protobuf/util/type_resolver.h" + #include "google/protobuf/util/type_resolver_util.h" +-#include "google/protobuf/stubs/status_macros.h" +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" ++#include "google/protobuf/wrappers.pb.h" + + namespace google { + namespace protobuf { +@@ -257,7 +255,6 @@ TEST_P(JsonTest, TestPreserveProtoFieldNames) { + JsonPrintOptions options; + options.preserve_proto_field_names = true; + EXPECT_THAT(ToJson(m, options), IsOkAndHolds("{\"message_value\":{}}")); +- + } + + TEST_P(JsonTest, Camels) { +@@ -971,7 +968,6 @@ TEST_P(JsonTest, TestOverwriteRepeated) { + EXPECT_THAT(m.repeated_int32_value(), ElementsAre(1, 2, 3)); + } + +- + TEST_P(JsonTest, TestDuration) { + auto m = ToProto(R"json( + { +diff --git a/src/google/protobuf/util/converter/location_tracker.h b/src/google/protobuf/util/converter/location_tracker.h +index 1246114..5c896f2 100644 +--- a/src/google/protobuf/util/converter/location_tracker.h ++++ b/src/google/protobuf/util/converter/location_tracker.h +@@ -19,9 +19,6 @@ + + #include + +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { +@@ -29,7 +26,7 @@ namespace converter { + + // LocationTrackerInterface is an interface for classes that track + // the location information for the purpose of error reporting. +-class PROTOBUF_EXPORT LocationTrackerInterface { ++class LocationTrackerInterface { + public: + LocationTrackerInterface(const LocationTrackerInterface&) = delete; + LocationTrackerInterface& operator=(const LocationTrackerInterface&) = delete; +@@ -50,6 +47,4 @@ class PROTOBUF_EXPORT LocationTrackerInterface { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H_ +diff --git a/src/google/protobuf/util/converter/object_source.h b/src/google/protobuf/util/converter/object_source.h +index 6a780d5..6d048aa 100644 +--- a/src/google/protobuf/util/converter/object_source.h ++++ b/src/google/protobuf/util/converter/object_source.h +@@ -20,10 +20,6 @@ + #include "absl/status/status.h" + #include "absl/strings/string_view.h" + +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { +@@ -37,7 +33,7 @@ class ObjectWriter; + // example, a character stream, or protobuf. + // + // Derived classes could be thread-unsafe. +-class PROTOBUF_EXPORT ObjectSource { ++class ObjectSource { + public: + ObjectSource(const ObjectSource&) = delete; + ObjectSource& operator=(const ObjectSource&) = delete; +@@ -63,6 +59,4 @@ class PROTOBUF_EXPORT ObjectSource { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H_ +diff --git a/src/google/protobuf/util/converter/object_writer.h b/src/google/protobuf/util/converter/object_writer.h +index 499d9c0..5a7df8e 100644 +--- a/src/google/protobuf/util/converter/object_writer.h ++++ b/src/google/protobuf/util/converter/object_writer.h +@@ -19,19 +19,13 @@ + + #include + +-#include "google/protobuf/stubs/common.h" +- + #include "absl/strings/string_view.h" + +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { + namespace converter { + +- + class DataPiece; + + // An ObjectWriter is an interface for writing a stream of events +@@ -48,7 +42,7 @@ class DataPiece; + // + // TODO(xinb): seems like a prime candidate to apply the RAII paradigm + // and get rid the need to call EndXXX(). +-class PROTOBUF_EXPORT ObjectWriter { ++class ObjectWriter { + public: + ObjectWriter(const ObjectWriter&) = delete; + ObjectWriter& operator=(const ObjectWriter&) = delete; +@@ -83,7 +77,6 @@ class PROTOBUF_EXPORT ObjectWriter { + virtual ObjectWriter* RenderUint64(absl::string_view name, + uint64_t value) = 0; + +- + // Renders a double value. + virtual ObjectWriter* RenderDouble(absl::string_view name, double value) = 0; + // Renders a float value. +@@ -100,12 +93,10 @@ class PROTOBUF_EXPORT ObjectWriter { + // Renders a Null value. + virtual ObjectWriter* RenderNull(absl::string_view name) = 0; + +- + // Renders a DataPiece object to a ObjectWriter. + static void RenderDataPieceTo(const DataPiece& data, absl::string_view name, + ObjectWriter* ow); + +- + // Indicates whether this ObjectWriter has completed writing the root message, + // usually this means writing of one complete object. Subclasses must override + // this behavior appropriately. +@@ -133,6 +124,4 @@ class PROTOBUF_EXPORT ObjectWriter { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H_ +diff --git a/src/google/protobuf/util/converter/proto_writer.cc b/src/google/protobuf/util/converter/proto_writer.cc +index 2683c08..f1f718e 100644 +--- a/src/google/protobuf/util/converter/proto_writer.cc ++++ b/src/google/protobuf/util/converter/proto_writer.cc +@@ -34,10 +34,6 @@ + #include "google/protobuf/util/converter/utility.h" + #include "google/protobuf/wire_format_lite.h" + +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { +@@ -45,7 +41,6 @@ namespace converter { + using ::google::protobuf::internal::WireFormatLite; + using ::google::protobuf::io::CodedOutputStream; + +- + ProtoWriter::ProtoWriter(TypeResolver* type_resolver, + const google::protobuf::Type& type, + strings::ByteSink* output, ErrorListener* listener) +@@ -437,8 +432,7 @@ void ProtoWriter::MissingField(absl::string_view missing_name) { + listener_->MissingField(location(), missing_name); + } + +-ProtoWriter* ProtoWriter::StartObject( +- absl::string_view name) { ++ProtoWriter* ProtoWriter::StartObject(absl::string_view name) { + // Starting the root message. Create the root ProtoElement and return. + if (element_ == nullptr) { + if (!name.empty()) { +@@ -470,7 +464,6 @@ ProtoWriter* ProtoWriter::StartObject( + return StartObjectField(*field, *type); + } + +- + ProtoWriter* ProtoWriter::EndObject() { + if (invalid_depth_ > 0) { + --invalid_depth_; +@@ -481,7 +474,6 @@ ProtoWriter* ProtoWriter::EndObject() { + element_.reset(element_->pop()); + } + +- + // If ending the root element, + // then serialize the full message with calculated sizes. + if (element_ == nullptr) { +@@ -490,9 +482,7 @@ ProtoWriter* ProtoWriter::EndObject() { + return this; + } + +-ProtoWriter* ProtoWriter::StartList( +- absl::string_view name) { +- ++ProtoWriter* ProtoWriter::StartList(absl::string_view name) { + const google::protobuf::Field* field = BeginNamed(name, true); + + if (field == nullptr) return this; +@@ -513,7 +503,6 @@ ProtoWriter* ProtoWriter::StartList( + return StartListField(*field, *type); + } + +- + ProtoWriter* ProtoWriter::EndList() { + if (invalid_depth_ > 0) { + --invalid_depth_; +@@ -523,8 +512,8 @@ ProtoWriter* ProtoWriter::EndList() { + return this; + } + +-ProtoWriter* ProtoWriter::RenderDataPiece( +- absl::string_view name, const DataPiece& data) { ++ProtoWriter* ProtoWriter::RenderDataPiece(absl::string_view name, ++ const DataPiece& data) { + absl::Status status; + if (invalid_depth_ > 0) return this; + +@@ -568,7 +557,7 @@ bool ProtoWriter::IsRepeated(const google::protobuf::Field& field) { + + ProtoWriter* ProtoWriter::StartObjectField(const google::protobuf::Field& field, + const google::protobuf::Type& type) { +- WriteTag(field); ++ WriteTag(field); + element_.reset(new ProtoElement(element_.release(), &field, type, false)); + return this; + } +@@ -803,7 +792,6 @@ void ProtoWriter::WriteTag(const google::protobuf::Field& field) { + stream_->WriteTag(WireFormatLite::MakeTag(field.number(), wire_type)); + } + +- + } // namespace converter + } // namespace util + } // namespace protobuf +diff --git a/src/google/protobuf/util/converter/proto_writer.h b/src/google/protobuf/util/converter/proto_writer.h +index dd28102..bce0d4a 100644 +--- a/src/google/protobuf/util/converter/proto_writer.h ++++ b/src/google/protobuf/util/converter/proto_writer.h +@@ -22,29 +22,24 @@ + #include + #include + +-#include "google/protobuf/type.pb.h" +-#include "google/protobuf/descriptor.h" + #include "absl/container/flat_hash_set.h" + #include "absl/status/status.h" ++#include "google/protobuf/descriptor.h" ++#include "google/protobuf/io/coded_stream.h" ++#include "google/protobuf/io/zero_copy_stream_impl.h" + #include "google/protobuf/stubs/bytestream.h" ++#include "google/protobuf/type.pb.h" + #include "google/protobuf/util/converter/datapiece.h" + #include "google/protobuf/util/converter/error_listener.h" + #include "google/protobuf/util/converter/structured_objectwriter.h" + #include "google/protobuf/util/converter/type_info.h" +-#include "google/protobuf/io/coded_stream.h" +-#include "google/protobuf/io/zero_copy_stream_impl.h" + #include "google/protobuf/util/type_resolver.h" + +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { + namespace converter { + +- + class ObjectLocationTracker; + + // An ObjectWriter that can write protobuf bytes directly from writer events. +@@ -53,9 +48,9 @@ class ObjectLocationTracker; + // special types by inheriting from it or by wrapping it. + // + // It also supports streaming. +-class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { ++class ProtoWriter : public StructuredObjectWriter { + public: +-// Constructor. Does not take ownership of any parameter passed in. ++ // Constructor. Does not take ownership of any parameter passed in. + ProtoWriter(TypeResolver* type_resolver, const google::protobuf::Type& type, + strings::ByteSink* output, ErrorListener* listener); + ProtoWriter() = delete; +@@ -105,13 +100,11 @@ class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { + return RenderDataPiece(name, DataPiece::NullData()); + } + +- + // Renders a DataPiece 'value' into a field whose wire type is determined + // from the given field 'name'. + virtual ProtoWriter* RenderDataPiece(absl::string_view name, + const DataPiece& data); + +- + // Returns the location tracker to use for tracking locations for errors. + const LocationTrackerInterface& location() { + return element_ != nullptr ? *element_ : *tracker_; +@@ -156,8 +149,7 @@ class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { + } + + protected: +- class PROTOBUF_EXPORT ProtoElement : public BaseElement, +- public LocationTrackerInterface { ++ class ProtoElement : public BaseElement, public LocationTrackerInterface { + public: + // Constructor for the root element. No parent nor field. + ProtoElement(const TypeInfo* typeinfo, const google::protobuf::Type& type, +@@ -278,7 +270,6 @@ class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { + // Helper method to write proto tags based on the given field. + void WriteTag(const google::protobuf::Field& field); + +- + // Returns true if the field for type_ can be set as a oneof. If field is not + // a oneof type, this function does nothing and returns true. + // If another field for this oneof is already set, this function returns +@@ -371,6 +362,4 @@ class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H_ +diff --git a/src/google/protobuf/util/converter/protostream_objectsource.cc b/src/google/protobuf/util/converter/protostream_objectsource.cc +index fa4fe38..fa64ccd 100644 +--- a/src/google/protobuf/util/converter/protostream_objectsource.cc ++++ b/src/google/protobuf/util/converter/protostream_objectsource.cc +@@ -18,10 +18,6 @@ + #include + #include + +-#include "google/protobuf/descriptor.h" +-#include "google/protobuf/unknown_field_set.h" +-#include "google/protobuf/stubs/strutil.h" +-#include "google/protobuf/stubs/strutil.h" + #include "absl/base/call_once.h" + #include "absl/base/casts.h" + #include "absl/container/btree_map.h" +@@ -32,19 +28,17 @@ + #include "absl/strings/str_format.h" + #include "absl/strings/string_view.h" + #include "absl/time/time.h" ++#include "google/protobuf/descriptor.h" ++#include "google/protobuf/io/coded_stream.h" ++#include "google/protobuf/io/zero_copy_stream_impl.h" ++#include "google/protobuf/stubs/status_macros.h" ++#include "google/protobuf/stubs/strutil.h" ++#include "google/protobuf/unknown_field_set.h" + #include "google/protobuf/util/converter/constants.h" + #include "google/protobuf/util/converter/field_mask_utility.h" + #include "google/protobuf/util/converter/utility.h" +-#include "google/protobuf/io/coded_stream.h" +-#include "google/protobuf/io/zero_copy_stream_impl.h" + #include "google/protobuf/wire_format.h" + #include "google/protobuf/wire_format_lite.h" +-#include "google/protobuf/stubs/status_macros.h" +- +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + + namespace google { + namespace protobuf { +@@ -94,7 +88,6 @@ absl::StatusOr MapKeyDefaultValueAsString( + } + } // namespace + +- + ProtoStreamObjectSource::ProtoStreamObjectSource( + io::CodedInputStream* stream, TypeResolver* type_resolver, + const google::protobuf::Type& type, const RenderOptions& render_options) +@@ -162,7 +155,6 @@ absl::Status ProtoStreamObjectSource::WriteMessage( + const google::protobuf::Type& type, absl::string_view name, + const uint32_t end_tag, bool include_start_and_end, + ObjectWriter* ow) const { +- + const TypeRenderer* type_renderer = FindTypeRenderer(type.name()); + if (type_renderer != nullptr) { + return (*type_renderer)(this, type, name, ow); +@@ -174,7 +166,6 @@ absl::Status ProtoStreamObjectSource::WriteMessage( + uint32_t tag = stream_->ReadTag(), last_tag = tag + 1; + UnknownFieldSet unknown_fields; + +- + if (include_start_and_end) { + ow->StartObject(name); + } +@@ -193,9 +184,7 @@ absl::Status ProtoStreamObjectSource::WriteMessage( + if (field == nullptr) { + // If we didn't find a field, skip this unknown tag. + // TODO(wpoon): Check return boolean value. +- WireFormat::SkipField( +- stream_, tag, +- nullptr); ++ WireFormat::SkipField(stream_, tag, nullptr); + tag = stream_->ReadTag(); + continue; + } +@@ -215,7 +204,6 @@ absl::Status ProtoStreamObjectSource::WriteMessage( + } + } + +- + if (include_start_and_end) { + ow->EndObject(); + } +@@ -323,12 +311,7 @@ absl::Status ProtoStreamObjectSource::RenderTimestamp( + std::string formatted_seconds = + absl::FormatTime(kRfc3339TimeFormat, tm, absl::UTCTimeZone()); + std::string formatted_time = absl::StrFormat( +- "%s%sZ", formatted_seconds.c_str(), +- FormatNanos( +- nanos, +- false +- ) +- .c_str()); ++ "%s%sZ", formatted_seconds.c_str(), FormatNanos(nanos, false).c_str()); + ow->RenderString(field_name, formatted_time); + return absl::Status(); + } +@@ -366,11 +349,7 @@ absl::Status ProtoStreamObjectSource::RenderDuration( + } + std::string formatted_duration = absl::StrFormat( + "%s%lld%ss", sign.c_str(), static_cast(seconds), // NOLINT +- FormatNanos( +- nanos, +- false +- ) +- .c_str()); ++ FormatNanos(nanos, false).c_str()); + ow->RenderString(field_name, formatted_duration); + return absl::Status(); + } +@@ -665,12 +644,10 @@ absl::Status ProtoStreamObjectSource::RenderFieldMask( + return absl::Status(); + } + +- + absl::flat_hash_map* + ProtoStreamObjectSource::renderers_ = nullptr; + absl::once_flag source_renderers_init_; + +- + void ProtoStreamObjectSource::InitRendererMap() { + renderers_ = new absl::flat_hash_map(); +@@ -866,10 +843,10 @@ absl::Status ProtoStreamObjectSource::RenderNonMessageField( + ow->RenderString(field_name, enum_value->name()); + } + } else { +- ow->RenderInt32(field_name, buffer32); ++ ow->RenderInt32(field_name, buffer32); + } + } else { +- ow->RenderInt32(field_name, buffer32); ++ ow->RenderInt32(field_name, buffer32); + } + break; + } +diff --git a/src/google/protobuf/util/converter/protostream_objectsource.h b/src/google/protobuf/util/converter/protostream_objectsource.h +index b962707..fb10442 100644 +--- a/src/google/protobuf/util/converter/protostream_objectsource.h ++++ b/src/google/protobuf/util/converter/protostream_objectsource.h +@@ -23,21 +23,16 @@ + #include + #include + +-#include "google/protobuf/stubs/common.h" +-#include "google/protobuf/type.pb.h" + #include "absl/container/flat_hash_map.h" + #include "absl/status/status.h" + #include "absl/status/statusor.h" + #include "absl/strings/string_view.h" ++#include "google/protobuf/type.pb.h" + #include "google/protobuf/util/converter/object_source.h" + #include "google/protobuf/util/converter/object_writer.h" + #include "google/protobuf/util/converter/type_info.h" + #include "google/protobuf/util/type_resolver.h" + +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { +@@ -58,9 +53,8 @@ class TypeInfo; + // ); + // + // Status status = os.WriteTo(); +-class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { ++class ProtoStreamObjectSource : public ObjectSource { + public: +- + struct RenderOptions { + // Sets whether or not to use lowerCamelCase casing for enum values. If set + // to false, enum values are output without any case conversions. +@@ -94,7 +88,6 @@ class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { + + // Whether to preserve proto field names + bool preserve_proto_field_names = false; +- + }; + + ProtoStreamObjectSource(io::CodedInputStream* stream, +@@ -158,7 +151,6 @@ class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { + std::string ReadFieldValueAsString( + const google::protobuf::Field& field) const; + +- + // Returns the input stream. + io::CodedInputStream* stream() const { return stream_; } + +@@ -266,7 +258,6 @@ class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { + absl::string_view field_name, + ObjectWriter* ow) const; + +- + // Utility function to detect proto maps. The 'field' MUST be repeated. + bool IsMap(const google::protobuf::Field& field) const; + +@@ -295,7 +286,6 @@ class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { + // google::protobuf::Type of the message source. + const google::protobuf::Type& type_; + +- + const RenderOptions render_options_; + + // Tracks current recursion depth. +@@ -310,6 +300,4 @@ class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H_ +diff --git a/src/google/protobuf/util/converter/protostream_objectwriter.cc b/src/google/protobuf/util/converter/protostream_objectwriter.cc +index 5489063..cfe426b 100644 +--- a/src/google/protobuf/util/converter/protostream_objectwriter.cc ++++ b/src/google/protobuf/util/converter/protostream_objectwriter.cc +@@ -18,7 +18,6 @@ + #include + #include + +-#include "google/protobuf/stubs/strutil.h" + #include "absl/base/call_once.h" + #include "absl/log/absl_check.h" + #include "absl/log/absl_log.h" +@@ -28,16 +27,13 @@ + #include "absl/strings/str_cat.h" + #include "absl/strings/strip.h" + #include "absl/time/time.h" ++#include "google/protobuf/stubs/strutil.h" + #include "google/protobuf/util/converter/constants.h" + #include "google/protobuf/util/converter/field_mask_utility.h" + #include "google/protobuf/util/converter/object_location_tracker.h" + #include "google/protobuf/util/converter/utility.h" + #include "google/protobuf/wire_format_lite.h" + +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { +@@ -47,7 +43,6 @@ using ::absl::Status; + using ::google::protobuf::internal::WireFormatLite; + using std::placeholders::_1; + +- + ProtoStreamObjectWriter::ProtoStreamObjectWriter( + TypeResolver* type_resolver, const google::protobuf::Type& type, + strings::ByteSink* output, ErrorListener* listener, +@@ -482,7 +477,6 @@ bool ProtoStreamObjectWriter::Item::InsertMapKeyIfNotPresent( + return map_keys_.insert(std::string(map_key)).second; + } + +- + ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartObject( + absl::string_view name) { + if (invalid_depth() > 0) { +@@ -678,7 +672,6 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::EndObject() { + return this; + } + +- + ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartList( + absl::string_view name) { + if (invalid_depth() > 0) { +@@ -924,8 +917,7 @@ Status ProtoStreamObjectWriter::RenderStructValue(ProtoStreamObjectWriter* ow, + absl::StatusOr int_value = data.ToInt32(); + if (int_value.ok()) { + ow->ProtoWriter::RenderDataPiece( +- "string_value", +- DataPiece(SimpleDtoa(int_value.value()), true)); ++ "string_value", DataPiece(SimpleDtoa(int_value.value()), true)); + return Status(); + } + } +@@ -937,8 +929,7 @@ Status ProtoStreamObjectWriter::RenderStructValue(ProtoStreamObjectWriter* ow, + absl::StatusOr int_value = data.ToUint32(); + if (int_value.ok()) { + ow->ProtoWriter::RenderDataPiece( +- "string_value", +- DataPiece(SimpleDtoa(int_value.value()), true)); ++ "string_value", DataPiece(SimpleDtoa(int_value.value()), true)); + return Status(); + } + } +@@ -978,8 +969,7 @@ Status ProtoStreamObjectWriter::RenderStructValue(ProtoStreamObjectWriter* ow, + absl::StatusOr float_value = data.ToFloat(); + if (float_value.ok()) { + ow->ProtoWriter::RenderDataPiece( +- "string_value", +- DataPiece(SimpleDtoa(float_value.value()), true)); ++ "string_value", DataPiece(SimpleDtoa(float_value.value()), true)); + return Status(); + } + } +@@ -1368,9 +1358,9 @@ bool ProtoStreamObjectWriter::ValidMapKey(absl::string_view unnormalized_name) { + return true; + } + +-void ProtoStreamObjectWriter::Push( +- absl::string_view name, Item::ItemType item_type, bool is_placeholder, +- bool is_list) { ++void ProtoStreamObjectWriter::Push(absl::string_view name, ++ Item::ItemType item_type, ++ bool is_placeholder, bool is_list) { + is_list ? ProtoWriter::StartList(name) : ProtoWriter::StartObject(name); + + // invalid_depth == 0 means it is a successful StartObject or StartList. +diff --git a/src/google/protobuf/util/converter/protostream_objectwriter.h b/src/google/protobuf/util/converter/protostream_objectwriter.h +index c9a93f7..92fcc0f 100644 +--- a/src/google/protobuf/util/converter/protostream_objectwriter.h ++++ b/src/google/protobuf/util/converter/protostream_objectwriter.h +@@ -20,25 +20,21 @@ + #include + #include + +-#include "google/protobuf/type.pb.h" +-#include "google/protobuf/descriptor.h" + #include "absl/container/flat_hash_set.h" + #include "absl/status/status.h" +-#include "google/protobuf/stubs/bytestream.h" + #include "absl/strings/string_view.h" ++#include "google/protobuf/descriptor.h" ++#include "google/protobuf/io/coded_stream.h" ++#include "google/protobuf/io/zero_copy_stream_impl.h" ++#include "google/protobuf/stubs/bytestream.h" ++#include "google/protobuf/type.pb.h" + #include "google/protobuf/util/converter/datapiece.h" + #include "google/protobuf/util/converter/error_listener.h" + #include "google/protobuf/util/converter/proto_writer.h" + #include "google/protobuf/util/converter/structured_objectwriter.h" + #include "google/protobuf/util/converter/type_info.h" +-#include "google/protobuf/io/coded_stream.h" +-#include "google/protobuf/io/zero_copy_stream_impl.h" + #include "google/protobuf/util/type_resolver.h" + +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { +@@ -51,7 +47,7 @@ class ObjectLocationTracker; + // the ProtoWriter class to write raw proto bytes. + // + // It also supports streaming. +-class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { ++class ProtoStreamObjectWriter : public ProtoWriter { + public: + // Options that control ProtoStreamObjectWriter class's behavior. + struct Options { +@@ -158,7 +154,7 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { + const DataPiece&); + + // Handles writing Anys out using nested object writers and the like. +- class PROTOBUF_EXPORT AnyWriter { ++ class AnyWriter { + public: + explicit AnyWriter(ProtoStreamObjectWriter* parent); + ~AnyWriter(); +@@ -183,7 +179,7 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { + private: + // Before the "@type" field is encountered, we store all incoming data + // into this Event struct and replay them after we get the "@type" field. +- class PROTOBUF_EXPORT Event { ++ class Event { + public: + enum Type { + START_OBJECT = 0, +@@ -272,7 +268,7 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { + + // Represents an item in a stack of items used to keep state between + // ObjectWrier events. +- class PROTOBUF_EXPORT Item : public BaseElement { ++ class Item : public BaseElement { + public: + // Indicates the type of item. + enum ItemType { +@@ -405,7 +401,6 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { + void Push(absl::string_view name, Item::ItemType item_type, + bool is_placeholder, bool is_list); + +- + // Pops items from the stack. All placeholder items are popped until a + // non-placeholder item is found. + void Pop(); +@@ -435,6 +430,4 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H_ +diff --git a/src/google/protobuf/util/converter/structured_objectwriter.h b/src/google/protobuf/util/converter/structured_objectwriter.h +index ada20d6..656ab13 100644 +--- a/src/google/protobuf/util/converter/structured_objectwriter.h ++++ b/src/google/protobuf/util/converter/structured_objectwriter.h +@@ -21,10 +21,7 @@ + + #include "absl/base/casts.h" + #include "google/protobuf/util/converter/object_writer.h" +- +-// Must be included last. + #include "google/protobuf/util/converter/port.h" +-#include "google/protobuf/util/converter/port_def.inc" + + namespace google { + namespace protobuf { +@@ -42,7 +39,7 @@ namespace converter { + // StructuredObjectWriter and its use. + // + // Derived classes could be thread-unsafe. +-class PROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter { ++class StructuredObjectWriter : public ObjectWriter { + public: + StructuredObjectWriter(const StructuredObjectWriter&) = delete; + StructuredObjectWriter& operator=(const StructuredObjectWriter&) = delete; +@@ -54,7 +51,7 @@ class PROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter { + // StructuredObjectWriter behaves as a visitor. BaseElement represents a node + // in the input tree. Implementation of StructuredObjectWriter should also + // extend BaseElement to keep track of the location in the input tree. +- class PROTOBUF_EXPORT BaseElement { ++ class BaseElement { + public: + // Takes ownership of the parent Element. + explicit BaseElement(BaseElement* parent) +@@ -105,6 +102,4 @@ class PROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_STRUCTURED_OBJECTWRITER_H_ +diff --git a/src/google/protobuf/util/converter/type_info.h b/src/google/protobuf/util/converter/type_info.h +index f1caf90..8884e5f 100644 +--- a/src/google/protobuf/util/converter/type_info.h ++++ b/src/google/protobuf/util/converter/type_info.h +@@ -17,23 +17,19 @@ + #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H_ + #define GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H_ + +-#include "google/protobuf/type.pb.h" + #include "absl/status/status.h" + #include "absl/status/statusor.h" + #include "absl/strings/string_view.h" ++#include "google/protobuf/type.pb.h" + #include "google/protobuf/util/type_resolver.h" + +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" +- + namespace google { + namespace protobuf { + namespace util { + namespace converter { + // Internal helper class for type resolving. Note that this class is not + // thread-safe and should only be accessed in one thread. +-class PROTOBUF_EXPORT TypeInfo { ++class TypeInfo { + public: + TypeInfo() {} + TypeInfo(const TypeInfo&) = delete; +@@ -77,6 +73,4 @@ class PROTOBUF_EXPORT TypeInfo { + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H_ +diff --git a/src/google/protobuf/util/converter/utility.cc b/src/google/protobuf/util/converter/utility.cc +index 0770b0a..4007424 100644 +--- a/src/google/protobuf/util/converter/utility.cc ++++ b/src/google/protobuf/util/converter/utility.cc +@@ -20,22 +20,17 @@ + #include + #include + +-#include "google/protobuf/stubs/callback.h" +-#include "google/protobuf/stubs/common.h" +-#include "google/protobuf/wrappers.pb.h" +-#include "google/protobuf/descriptor.pb.h" +-#include "google/protobuf/descriptor.h" +-#include "google/protobuf/stubs/strutil.h" + #include "absl/container/flat_hash_set.h" + #include "absl/strings/ascii.h" + #include "absl/strings/cord.h" + #include "absl/strings/match.h" + #include "absl/strings/str_cat.h" + #include "absl/strings/string_view.h" ++#include "google/protobuf/descriptor.h" ++#include "google/protobuf/descriptor.pb.h" ++#include "google/protobuf/stubs/strutil.h" + #include "google/protobuf/util/converter/constants.h" +- +-// must be last +-#include "google/protobuf/util/converter/port_def.inc" ++#include "google/protobuf/wrappers.pb.h" + + namespace google { + namespace protobuf { +diff --git a/src/google/protobuf/util/converter/utility.h b/src/google/protobuf/util/converter/utility.h +index a98793b..f00ad3a 100644 +--- a/src/google/protobuf/util/converter/utility.h ++++ b/src/google/protobuf/util/converter/utility.h +@@ -22,19 +22,13 @@ + #include + #include + +-#include "google/protobuf/stubs/common.h" +-#include "google/protobuf/any.pb.h" +-#include "google/protobuf/type.pb.h" +-#include "google/protobuf/repeated_field.h" +-#include "google/protobuf/stubs/strutil.h" + #include "absl/status/status.h" + #include "absl/status/statusor.h" + #include "absl/strings/str_cat.h" + #include "absl/strings/string_view.h" +- +- +-// Must be included last. +-#include "google/protobuf/util/converter/port_def.inc" ++#include "google/protobuf/any.pb.h" ++#include "google/protobuf/repeated_field.h" ++#include "google/protobuf/type.pb.h" + + namespace google { + namespace protobuf { +@@ -47,25 +41,25 @@ static const int64_t kTypeUrlSize = 19; + // Finds the tech option identified by option_name. Parses the boolean value and + // returns it. + // When the option with the given name is not found, default_value is returned. +-PROTOBUF_EXPORT bool GetBoolOptionOrDefault( ++bool GetBoolOptionOrDefault( + const RepeatedPtrField& options, + absl::string_view option_name, bool default_value); + + // Returns int64 option value. If the option isn't found, returns the + // default_value. +-PROTOBUF_EXPORT int64_t GetInt64OptionOrDefault( ++int64_t GetInt64OptionOrDefault( + const RepeatedPtrField& options, + absl::string_view option_name, int64_t default_value); + + // Returns double option value. If the option isn't found, returns the + // default_value. +-PROTOBUF_EXPORT double GetDoubleOptionOrDefault( ++double GetDoubleOptionOrDefault( + const RepeatedPtrField& options, + absl::string_view option_name, double default_value); + + // Returns string option value. If the option isn't found, returns the + // default_value. +-PROTOBUF_EXPORT std::string GetStringOptionOrDefault( ++std::string GetStringOptionOrDefault( + const RepeatedPtrField& options, + absl::string_view option_name, absl::string_view default_value); + +@@ -73,21 +67,20 @@ PROTOBUF_EXPORT std::string GetStringOptionOrDefault( + // TODO(skarvaje): Make these utilities dealing with Any types more generic, + // add more error checking and move to a more public/shareable location so + // others can use. +-PROTOBUF_EXPORT bool GetBoolFromAny(const google::protobuf::Any& any); ++bool GetBoolFromAny(const google::protobuf::Any& any); + + // Returns int64 value contained in Any type. +-PROTOBUF_EXPORT int64_t GetInt64FromAny(const google::protobuf::Any& any); ++int64_t GetInt64FromAny(const google::protobuf::Any& any); + + // Returns double value contained in Any type. +-PROTOBUF_EXPORT double GetDoubleFromAny(const google::protobuf::Any& any); ++double GetDoubleFromAny(const google::protobuf::Any& any); + + // Returns string value contained in Any type. +-PROTOBUF_EXPORT std::string GetStringFromAny(const google::protobuf::Any& any); ++std::string GetStringFromAny(const google::protobuf::Any& any); + + // Returns the type string without the url prefix. e.g.: If the passed type is + // 'type.googleapis.com/tech.type.Bool', the returned value is 'tech.type.Bool'. +-PROTOBUF_EXPORT absl::string_view GetTypeWithoutUrl( +- absl::string_view type_url); ++absl::string_view GetTypeWithoutUrl(absl::string_view type_url); + + // Returns the simple_type with the base type url (kTypeServiceBaseUrl) + // prefixed. +@@ -95,8 +88,7 @@ PROTOBUF_EXPORT absl::string_view GetTypeWithoutUrl( + // E.g: + // GetFullTypeWithUrl("google.protobuf.Timestamp") returns the string + // "type.googleapis.com/google.protobuf.Timestamp". +-PROTOBUF_EXPORT std::string GetFullTypeWithUrl( +- absl::string_view simple_type); ++std::string GetFullTypeWithUrl(absl::string_view simple_type); + + // Finds and returns option identified by name and option_name within the + // provided map. Returns nullptr if none found. +@@ -136,31 +128,31 @@ const google::protobuf::EnumValue* FindEnumValueByNameWithoutUnderscoreOrNull( + const google::protobuf::Enum* enum_type, absl::string_view enum_name); + + // Converts input to camel-case and returns it. +-PROTOBUF_EXPORT std::string ToCamelCase(const absl::string_view input); ++std::string ToCamelCase(const absl::string_view input); + + // Converts enum name string to camel-case and returns it. + std::string EnumValueNameToLowerCamelCase(const absl::string_view input); + + // Converts input to snake_case and returns it. +-PROTOBUF_EXPORT std::string ToSnakeCase(absl::string_view input); ++std::string ToSnakeCase(absl::string_view input); + + // Returns true if type_name represents a well-known type. +-PROTOBUF_EXPORT bool IsWellKnownType(const std::string& type_name); ++bool IsWellKnownType(const std::string& type_name); + + // Returns true if 'bool_string' represents a valid boolean value. Only "true", + // "false", "0" and "1" are allowed. +-PROTOBUF_EXPORT bool IsValidBoolString(absl::string_view bool_string); ++bool IsValidBoolString(absl::string_view bool_string); + + // Returns true if "field" is a protobuf map field based on its type. +-PROTOBUF_EXPORT bool IsMap(const google::protobuf::Field& field, +- const google::protobuf::Type& type); ++bool IsMap(const google::protobuf::Field& field, ++ const google::protobuf::Type& type); + + // Returns true if the given type has special MessageSet wire format. + bool IsMessageSetWireFormat(const google::protobuf::Type& type); + + // Infinity/NaN-aware conversion to string. +-PROTOBUF_EXPORT std::string DoubleAsString(double value); +-PROTOBUF_EXPORT std::string FloatAsString(float value); ++std::string DoubleAsString(double value); ++std::string FloatAsString(float value); + + // Convert from int32, int64, uint32, uint64, double or float to string. + template +@@ -180,13 +172,11 @@ inline std::string ValueAsString(double value) { + + // Converts a string to float. Unlike safe_strtof, conversion will fail if the + // value fits into double but not float (e.g., DBL_MAX). +-PROTOBUF_EXPORT bool SafeStrToFloat(absl::string_view str, float* value); ++bool SafeStrToFloat(absl::string_view str, float* value); + + } // namespace converter + } // namespace util + } // namespace protobuf + } // namespace google + +-#include "google/protobuf/util/converter/port_undef.inc" +- + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H_ diff --git a/bazel/envoy_select.bzl b/bazel/envoy_select.bzl index 873126819da0..2135eab05705 100644 --- a/bazel/envoy_select.bzl +++ b/bazel/envoy_select.bzl @@ -149,9 +149,6 @@ def envoy_select_wasm_cpp_tests(xs): def envoy_select_wasm_rust_tests(xs): return select({ "@envoy//bazel:wasm_disabled": [], - # TODO(phlax): re-enable once issues with llvm profiler are resolved - # (see https://github.com/envoyproxy/envoy/issues/24164) - "@envoy//bazel:coverage_build": [], "//conditions:default": xs, }) @@ -162,9 +159,6 @@ def envoy_select_wasm_v8(xs): "@envoy//bazel:wasm_wamr": [], "@envoy//bazel:wasm_wasmtime": [], "@envoy//bazel:wasm_disabled": [], - # TODO(phlax): re-enable once issues with llvm profiler are resolved - # (see https://github.com/envoyproxy/envoy/issues/24164) - "@envoy//bazel:coverage_build": [], "//conditions:default": xs, # implicit default (v8) }) @@ -175,9 +169,6 @@ def envoy_select_wasm_v8_bool(): "@envoy//bazel:wasm_wamr": False, "@envoy//bazel:wasm_wasmtime": False, "@envoy//bazel:wasm_disabled": False, - # TODO(phlax): re-enable once issues with llvm profiler are resolved - # (see https://github.com/envoyproxy/envoy/issues/24164) - "@envoy//bazel:coverage_build": False, "//conditions:default": True, # implicit default (v8) }) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 99f1d57d6c4d..6379ed63d369 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -79,6 +79,13 @@ def _cc_deps(): name = "com_google_protoconverter", patch_args = ["-p1"], patches = ["@envoy//bazel:com_google_protoconverter.patch"], + patch_cmds = [ + "rm src/google/protobuf/stubs/common.cc", + "rm src/google/protobuf/stubs/common.h", + "rm src/google/protobuf/stubs/common_unittest.cc", + "rm src/google/protobuf/util/converter/port_def.inc", + "rm src/google/protobuf/util/converter/port_undef.inc", + ], ) external_http_archive("com_google_protofieldextraction") external_http_archive("com_google_protoprocessinglib") diff --git a/bazel/rules_rust.patch b/bazel/rules_rust.patch index e00bfdfd006d..04fc47181b01 100644 --- a/bazel/rules_rust.patch +++ b/bazel/rules_rust.patch @@ -9,3 +9,15 @@ # These rules are not supposed to be depended on by other rust targets, and # as such they shouldn't provide a CrateInfo. However, one may still want to # write a rust_test for them, so we provide the CrateInfo wrapped in a provider + +--- rust/private/rustc.bzl ++++ rust/private/rustc.bzl +@@ -1043,7 +1043,7 @@ def construct_arguments( + + if toolchain.llvm_cov and ctx.configuration.coverage_enabled: + # https://doc.rust-lang.org/rustc/instrument-coverage.html +- rustc_flags.add("--codegen=instrument-coverage") ++ pass + + if toolchain._experimental_link_std_dylib: + rustc_flags.add("--codegen=prefer-dynamic") diff --git a/changelogs/current.yaml b/changelogs/current.yaml index 46f6352cf4af..b773fb76f626 100644 --- a/changelogs/current.yaml +++ b/changelogs/current.yaml @@ -397,6 +397,17 @@ new_features: - area: geoip change: | Added ``envoy.reloadable_features.mmdb_files_reload_enabled`` runtime flag that enables reload of mmdb files by default. +- area: access_log + change: | + Added new JSON access log formatter implementation which provides 16-25x performance improvement over the old + implementation. The legacy implementation will be enabled by default for now but will be deprecated and removed + in a future release. + The :ref:`sort_properties ` field will + be ignored in the new implementation because the new implementation always sorts properties. And the new implementation + will always keep the value type in the JSON output. For example, the duration field will always be rendered as a number + instead of a string. + The new JSON formatter could be enabled by setting the runtime guard + ``envoy.reloadable_features.logging_with_fast_json_formatter`` to true. - area: access_logs change: | Added support for %UPSTREAM_CONNECTION_ID% access log substitution string in TCP and UDP tunneling flows. diff --git a/envoy/http/original_ip_detection.h b/envoy/http/original_ip_detection.h index f5ddb13573af..e697ba486e2f 100644 --- a/envoy/http/original_ip_detection.h +++ b/envoy/http/original_ip_detection.h @@ -74,12 +74,12 @@ class OriginalIPDetectionFactory : public Envoy::Config::TypedFactory { ~OriginalIPDetectionFactory() override = default; /** - * Creates a particular extension implementation. + * Creates a particular extension implementation or return an error status. * * @param config supplies the configuration for the original IP detection extension. * @return OriginalIPDetectionSharedPtr the extension instance. */ - virtual OriginalIPDetectionSharedPtr + virtual absl::StatusOr createExtension(const Protobuf::Message& config, Server::Configuration::FactoryContext& context) PURE; diff --git a/envoy/upstream/upstream.h b/envoy/upstream/upstream.h index ca704d02fdb6..128834114002 100644 --- a/envoy/upstream/upstream.h +++ b/envoy/upstream/upstream.h @@ -308,17 +308,28 @@ class Host : virtual public HostDescription { public: virtual ~HostLbPolicyData() = default; }; - using HostLbPolicyDataPtr = std::shared_ptr; + using HostLbPolicyDataPtr = std::unique_ptr; - /* Takes ownership of lb_policy_data and attaches it to the host. - * Must be called before the host is used across threads. + /** + * Set load balancing policy related data to the host. + * NOTE: this method should only be called at main thread before the host is used + * across worker threads. */ virtual void setLbPolicyData(HostLbPolicyDataPtr lb_policy_data) PURE; - /* - * @return a reference to the LbPolicyData attached to the host. + /** + * Get the load balancing policy related data of the host. + * @return the optional reference to the load balancing policy related data of the host. */ - virtual const HostLbPolicyDataPtr& lbPolicyData() const PURE; + virtual OptRef lbPolicyData() const PURE; + + /** + * Get the typed load balancing policy related data of the host. + * @return the optional reference to the typed load balancing policy related data of the host. + */ + template OptRef typedLbPolicyData() const { + return makeOptRefFromPtr(dynamic_cast(lbPolicyData().ptr())); + } }; using HostConstSharedPtr = std::shared_ptr; diff --git a/mobile/test/performance/files_em_does_not_use b/mobile/test/performance/files_em_does_not_use index 16c1f69644f8..5d9be3672ef2 100644 --- a/mobile/test/performance/files_em_does_not_use +++ b/mobile/test/performance/files_em_does_not_use @@ -20,4 +20,3 @@ source/common/tls/ocsp/ocsp.h source/common/formatter/http_specific_formatter.h source/common/formatter/stream_info_formatter.h source/common/tls/default_tls_certificate_selector.h -source/common/json/json_streamer.h diff --git a/source/common/formatter/BUILD b/source/common/formatter/BUILD index eae108f64186..76a0fc474cfe 100644 --- a/source/common/formatter/BUILD +++ b/source/common/formatter/BUILD @@ -26,6 +26,7 @@ envoy_cc_library( "//source/common/http:header_map_lib", "//source/common/http:utility_lib", "//source/common/json:json_loader_lib", + "//source/common/json:json_streamer_lib", "@com_google_absl//absl/strings:str_format", "@envoy_api//envoy/config/core/v3:pkg_cc_proto", ], @@ -55,6 +56,7 @@ envoy_cc_library( "//source/common/http:header_utility_lib", "//source/common/http:utility_lib", "//source/common/protobuf:utility_lib", + "//source/common/runtime:runtime_features_lib", "//source/common/stream_info:utility_lib", ], ) diff --git a/source/common/formatter/substitution_format_string.h b/source/common/formatter/substitution_format_string.h index c66c77eaffd1..3a03ee3cfc08 100644 --- a/source/common/formatter/substitution_format_string.h +++ b/source/common/formatter/substitution_format_string.h @@ -12,6 +12,7 @@ #include "source/common/formatter/substitution_formatter.h" #include "source/common/protobuf/message_validator_impl.h" #include "source/common/protobuf/protobuf.h" +#include "source/common/runtime/runtime_features.h" #include "source/server/generic_factory_context.h" namespace Envoy { @@ -93,8 +94,15 @@ class SubstitutionFormatStringUtils { createJsonFormatter(const ProtobufWkt::Struct& struct_format, bool preserve_types, bool omit_empty_values, bool sort_properties, const std::vector>& commands = {}) { - return std::make_unique>( - struct_format, preserve_types, omit_empty_values, sort_properties, commands); + + if (!Runtime::runtimeFeatureEnabled( + "envoy.reloadable_features.logging_with_fast_json_formatter")) { + return std::make_unique>( + struct_format, preserve_types, omit_empty_values, sort_properties, commands); + } + + return std::make_unique>(struct_format, + omit_empty_values, commands); } }; diff --git a/source/common/formatter/substitution_formatter.cc b/source/common/formatter/substitution_formatter.cc index a3278cf5d71b..b24f821990ee 100644 --- a/source/common/formatter/substitution_formatter.cc +++ b/source/common/formatter/substitution_formatter.cc @@ -54,5 +54,95 @@ const re2::RE2& SubstitutionFormatParser::commandWithArgsRegex() { // clang-format on } +JsonFormatBuilder::FormatElements +JsonFormatBuilder::fromStruct(const ProtobufWkt::Struct& struct_format) { + elements_.clear(); + + // This call will iterate through the map tree and serialize the key/values as JSON. + // If a string value that contains a substitution commands is found, the current + // JSON piece and the substitution command will be pushed into the output list. + // After that, the iteration will continue until the whole tree is traversed. + formatValueToFormatElements(struct_format.fields()); + elements_.push_back(FormatElement{std::move(buffer_), false}); + buffer_.clear(); + + return std::move(elements_); +}; + +void JsonFormatBuilder::formatValueToFormatElements(const ProtobufWkt::Value& value) { + switch (value.kind_case()) { + case ProtobufWkt::Value::KIND_NOT_SET: + case ProtobufWkt::Value::kNullValue: + serializer_.addNull(); + break; + case ProtobufWkt::Value::kNumberValue: + serializer_.addNumber(value.number_value()); + break; + case ProtobufWkt::Value::kStringValue: { + absl::string_view string_format = value.string_value(); + if (!absl::StrContains(string_format, '%')) { + serializer_.addString(string_format); + break; + } + + // The string contains a formatter, we need to push the current exist JSON piece + // into the output list first. + elements_.push_back(FormatElement{std::move(buffer_), false}); + buffer_.clear(); + + // Now a formatter is coming, we need to push the current raw string into + // the output list. + elements_.push_back(FormatElement{std::string(string_format), true}); + break; + } + case ProtobufWkt::Value::kBoolValue: + serializer_.addBool(value.bool_value()); + break; + case ProtobufWkt::Value::kStructValue: { + formatValueToFormatElements(value.struct_value().fields()); + break; + case ProtobufWkt::Value::kListValue: + formatValueToFormatElements(value.list_value().values()); + break; + } + } +} + +void JsonFormatBuilder::formatValueToFormatElements(const ProtoList& list_value) { + serializer_.addArrayBeginDelimiter(); // Delimiter to start list. + for (int i = 0; i < list_value.size(); ++i) { + if (i > 0) { + serializer_.addElementsDelimiter(); // Delimiter to separate list elements. + } + formatValueToFormatElements(list_value[i]); + } + serializer_.addArrayEndDelimiter(); // Delimiter to end list. +} + +void JsonFormatBuilder::formatValueToFormatElements(const ProtoDict& dict_value) { + std::vector> sorted_fields; + sorted_fields.reserve(dict_value.size()); + + for (auto it = dict_value.begin(); it != dict_value.end(); ++it) { + sorted_fields.push_back({it->first, it}); + } + + // Sort the keys to make the output deterministic. + std::sort(sorted_fields.begin(), sorted_fields.end(), + [](const auto& a, const auto& b) { return a.first < b.first; }); + + serializer_.addMapBeginDelimiter(); // Delimiter to start map. + for (size_t i = 0; i < sorted_fields.size(); ++i) { + if (i > 0) { + serializer_.addElementsDelimiter(); // Delimiter to separate map elements. + } + // Add the key. + serializer_.addString(sorted_fields[i].first); + serializer_.addKeyValueDelimiter(); // Delimiter to separate key and value. + formatValueToFormatElements(sorted_fields[i].second->second); + } + serializer_.addMapEndDelimiter(); // Delimiter to end map. +} + } // namespace Formatter } // namespace Envoy diff --git a/source/common/formatter/substitution_formatter.h b/source/common/formatter/substitution_formatter.h index abf6ff5a69c7..c2f13903881c 100644 --- a/source/common/formatter/substitution_formatter.h +++ b/source/common/formatter/substitution_formatter.h @@ -15,6 +15,7 @@ #include "source/common/common/utility.h" #include "source/common/formatter/http_formatter_context.h" #include "source/common/json/json_loader.h" +#include "source/common/json/json_streamer.h" #include "absl/types/optional.h" #include "re2/re2.h" @@ -243,6 +244,260 @@ template class FormatterBaseImpl : public FormatterBase std::vector> providers_; }; +// Helper class to write value to output buffer in JSON style. +// NOTE: This helper class has duplicated logic with the Json::Streamer class but +// provides lower level of APIs to operate on the output buffer (like control the +// delimiters). This is designed for special scenario of substitution formatter and +// is not intended to be used by other parts of the code. +class JsonStringSerializer { +public: + using OutputBufferType = Json::StringOutput; + explicit JsonStringSerializer(std::string& output_buffer) : output_buffer_(output_buffer) {} + + // Methods that be used to add JSON delimiter to output buffer. + void addMapBeginDelimiter() { output_buffer_.add(Json::Constants::MapBegin); } + void addMapEndDelimiter() { output_buffer_.add(Json::Constants::MapEnd); } + void addArrayBeginDelimiter() { output_buffer_.add(Json::Constants::ArrayBegin); } + void addArrayEndDelimiter() { output_buffer_.add(Json::Constants::ArrayEnd); } + void addElementsDelimiter() { output_buffer_.add(Json::Constants::Comma); } + void addKeyValueDelimiter() { output_buffer_.add(Json::Constants::Colon); } + + // Methods that be used to add JSON key or value to output buffer. + void addString(absl::string_view value) { addSanitized(R"(")", value, R"(")"); } + /** + * Serializes a number. + */ + void addNumber(double d) { + if (std::isnan(d)) { + output_buffer_.add(Json::Constants::Null); + } else { + Buffer::Util::serializeDouble(d, output_buffer_); + } + } + /** + * Serializes a integer number. + * NOTE: All numbers in JSON is float. When loading output of this serializer, the parser's + * implementation decides if the full precision of big integer could be preserved or not. + * See discussion here https://stackoverflow.com/questions/13502398/json-integers-limit-on-size + * and spec https://www.rfc-editor.org/rfc/rfc7159#section-6 for more details. + */ + void addNumber(uint64_t i) { output_buffer_.add(absl::StrCat(i)); } + void addNumber(int64_t i) { output_buffer_.add(absl::StrCat(i)); } + void addBool(bool b) { output_buffer_.add(b ? Json::Constants::True : Json::Constants::False); } + void addNull() { output_buffer_.add(Json::Constants::Null); } + + // Low-level methods that be used to provide a low-level control to buffer. + void addSanitized(absl::string_view prefix, absl::string_view value, absl::string_view suffix) { + output_buffer_.add(prefix, Json::sanitize(sanitize_buffer_, value), suffix); + } + void addRawString(absl::string_view value) { output_buffer_.add(value); } + +protected: + std::string sanitize_buffer_; + OutputBufferType output_buffer_; +}; + +// Helper class to parse the Json format configuration. The class will be used to parse +// the JSON format configuration and convert it to a list of raw JSON pieces and +// substitution format template strings. See comments below for more details. +class JsonFormatBuilder { +public: + struct FormatElement { + // Pre-sanitized JSON piece or a format template string that contains + // substitution commands. + std::string value_; + // Whether the value is a template string. + // If true, the value is a format template string that contains substitution commands. + // If false, the value is a pre-sanitized JSON piece. + bool is_template_; + }; + using FormatElements = std::vector; + + /** + * Constructor of JsonFormatBuilder. + */ + JsonFormatBuilder() = default; + + /** + * Convert a proto struct format configuration to an array of raw JSON pieces and + * substitution format template strings. + * + * The keys, raw values, delimiters will be serialized as JSON string pieces (raw + * JSON strings) directly when loading the configuration. + * The substitution format template strings will be kept as template string pieces and + * will be parsed to formatter providers by the JsonFormatter. + * + * NOTE: This class is used to parse the configuration of the proto struct format + * and should only be used in the context of parsing the configuration. + * + * For example given the following proto struct format configuration: + * + * json_format: + * name: "value" + * template: "%START_TIME%" + * number: 2 + * bool: true + * list: + * - "list_raw_value" + * - false + * - "%EMIT_TIME%" + * nested: + * nested_name: "nested_value" + * + * It will be parsed to the following pieces: + * + * - '{"name":"value","template":' # Raw JSON piece. + * - '%START_TIME%' # Format template piece. + * - ',"number":2,"bool":true,"list":["list_raw_value",false,' # Raw JSON piece. + * - '%EMIT_TIME%' # Format template piece. + * - '],"nested":{"nested_name":"nested_value"}}' # Raw JSON piece. + * + * Finally, join the raw JSON pieces and output of substitution formatters in order + * to construct the final JSON output. + * + * @param struct_format the proto struct format configuration. + */ + FormatElements fromStruct(const ProtobufWkt::Struct& struct_format); + +private: + using ProtoDict = Protobuf::Map; + using ProtoList = Protobuf::RepeatedPtrField; + + void formatValueToFormatElements(const ProtoDict& dict_value); + void formatValueToFormatElements(const ProtobufWkt::Value& value); + void formatValueToFormatElements(const ProtoList& list_value); + + std::string buffer_; // JSON writer buffer. + JsonStringSerializer serializer_{buffer_}; // JSON serializer. + FormatElements elements_; // Parsed elements. +}; + +template +class JsonFormatterImplBase : public FormatterBase { +public: + using CommandParsers = std::vector>; + using Formatter = FormatterProviderBasePtr; + using Formatters = std::vector; + + JsonFormatterImplBase(const ProtobufWkt::Struct& struct_format, bool omit_empty_values, + const CommandParsers& commands = {}) + : empty_value_(omit_empty_values ? std::string() + : std::string(DefaultUnspecifiedValueStringView)) { + + for (JsonFormatBuilder::FormatElement& element : + JsonFormatBuilder().fromStruct(struct_format)) { + if (element.is_template_) { + parsed_elements_.emplace_back( + SubstitutionFormatParser::parse(element.value_, commands)); + } else { + parsed_elements_.emplace_back(std::move(element.value_)); + } + } + } + + std::string formatWithContext(const FormatterContext& context, + const StreamInfo::StreamInfo& info) const override { + std::string log_line; + log_line.reserve(2048); + JsonStringSerializer serializer(log_line); // Helper to serialize the value to log line. + + for (const ParsedFormatElement& element : parsed_elements_) { + // 1. Handle the raw string element. + if (absl::holds_alternative(element)) { + // The raw string element will be added to the buffer directly. + // It is sanitized when loading the configuration. + serializer.addRawString(absl::get(element)); + continue; + } + + ASSERT(absl::holds_alternative(element)); + const Formatters& formatters = absl::get(element); + ASSERT(!formatters.empty()); + + if (formatters.size() != 1) { + // 2. Handle the formatter element with multiple or zero providers. + stringValueToLogLine(formatters, context, info, serializer); + } else { + // 3. Handle the formatter element with a single provider and value + // type needs to be kept. + typedValueToLogLine(formatters, context, info, serializer); + } + } + + log_line.push_back('\n'); + return log_line; + } + +private: + void stringValueToLogLine(const Formatters& formatters, const FormatterContext& context, + const StreamInfo::StreamInfo& info, + JsonStringSerializer& serializer) const { + + serializer.addRawString(Json::Constants::DoubleQuote); // Start the JSON string. + for (const Formatter& formatter : formatters) { + const absl::optional value = formatter->formatWithContext(context, info); + if (!value.has_value()) { + // Add the empty value. This needn't be sanitized. + serializer.addRawString(empty_value_); + continue; + } + // Sanitize the string value and add it to the buffer. The string value will not be quoted + // since we handle the quoting by ourselves at the outer level. + serializer.addSanitized({}, value.value(), {}); + } + serializer.addRawString(Json::Constants::DoubleQuote); // End the JSON string. + } + + void typedValueToLogLine(const Formatters& formatters, const FormatterContext& context, + const StreamInfo::StreamInfo& info, + JsonStringSerializer& serializer) const { + + const ProtobufWkt::Value value = formatters[0]->formatValueWithContext(context, info); + + switch (value.kind_case()) { + case ProtobufWkt::Value::KIND_NOT_SET: + case ProtobufWkt::Value::kNullValue: + serializer.addNull(); + break; + case ProtobufWkt::Value::kNumberValue: + serializer.addNumber(value.number_value()); + break; + case ProtobufWkt::Value::kStringValue: + serializer.addString(value.string_value()); + break; + case ProtobufWkt::Value::kBoolValue: + serializer.addBool(value.bool_value()); + break; + case ProtobufWkt::Value::kStructValue: + case ProtobufWkt::Value::kListValue: + // Convert the struct or list to string. This may result in a performance + // degradation. But We rarely hit this case. + // Basically only metadata or filter state formatter may hit this case. +#ifdef ENVOY_ENABLE_YAML + absl::StatusOr json_or = + MessageUtil::getJsonStringFromMessage(value, false, true); + if (json_or.ok()) { + // We assume the output of getJsonStringFromMessage is a valid JSON string piece. + serializer.addRawString(json_or.value()); + } else { + serializer.addString(json_or.status().ToString()); + } +#else + IS_ENVOY_BUG("Json support compiled out"); + serializer.addRawString(R"EOF("Json support compiled out")EOF"); +#endif + break; + } + } + + const std::string empty_value_; + + using ParsedFormatElement = absl::variant; + std::vector parsed_elements_; +}; + +using JsonFormatterImpl = JsonFormatterImplBase; + // Helper classes for StructFormatter::StructFormatMapVisitor. template struct StructFormatMapVisitorHelper : Ts... { using Ts::operator()...; }; template StructFormatMapVisitorHelper(Ts...) -> StructFormatMapVisitorHelper; @@ -450,13 +705,13 @@ template using StructFormatterBasePtr = std::unique_ptr>; template -class JsonFormatterBaseImpl : public FormatterBase { +class LegacyJsonFormatterBaseImpl : public FormatterBase { public: using CommandParsers = std::vector>; - JsonFormatterBaseImpl(const ProtobufWkt::Struct& format_mapping, bool preserve_types, - bool omit_empty_values, bool sort_properties, - const CommandParsers& commands = {}) + LegacyJsonFormatterBaseImpl(const ProtobufWkt::Struct& format_mapping, bool preserve_types, + bool omit_empty_values, bool sort_properties, + const CommandParsers& commands = {}) : struct_formatter_(format_mapping, preserve_types, omit_empty_values, commands), sort_properties_(sort_properties) {} @@ -489,7 +744,7 @@ using StructFormatterPtr = std::unique_ptr; // Aliases for backwards compatibility. using FormatterImpl = FormatterBaseImpl; -using JsonFormatterImpl = JsonFormatterBaseImpl; +using LegacyJsonFormatterImpl = LegacyJsonFormatterBaseImpl; } // namespace Formatter } // namespace Envoy diff --git a/source/common/json/constants.h b/source/common/json/constants.h index 2207d6c7b5bb..1da68eda6b58 100644 --- a/source/common/json/constants.h +++ b/source/common/json/constants.h @@ -11,6 +11,15 @@ class Constants { static constexpr absl::string_view True = "true"; static constexpr absl::string_view False = "false"; static constexpr absl::string_view Null = "null"; + + // Constants for common JSON delimiters. + static constexpr absl::string_view DoubleQuote = "\""; + static constexpr absl::string_view Comma = ","; + static constexpr absl::string_view Colon = ":"; + static constexpr absl::string_view ArrayBegin = "["; + static constexpr absl::string_view ArrayEnd = "]"; + static constexpr absl::string_view MapBegin = "{"; + static constexpr absl::string_view MapEnd = "}"; }; } // namespace Json diff --git a/source/common/json/json_streamer.h b/source/common/json/json_streamer.h index ae18b7a38699..49239326e681 100644 --- a/source/common/json/json_streamer.h +++ b/source/common/json/json_streamer.h @@ -393,6 +393,13 @@ template class StreamerBase { Buffer::Util::serializeDouble(d, response_); } } + /** + * Serializes a integer number. + * NOTE: All numbers in JSON is float. When loading output of this serializer, the parser's + * implementation decides if the full precision of big integer could be preserved or not. + * See discussion here https://stackoverflow.com/questions/13502398/json-integers-limit-on-size + * and spec https://www.rfc-editor.org/rfc/rfc7159#section-6 for more details. + */ void addNumber(uint64_t u) { response_.add(absl::StrCat(u)); } void addNumber(int64_t i) { response_.add(absl::StrCat(i)); } diff --git a/source/common/router/scoped_config_impl.cc b/source/common/router/scoped_config_impl.cc index e6566a2f872c..c400649efe04 100644 --- a/source/common/router/scoped_config_impl.cc +++ b/source/common/router/scoped_config_impl.cc @@ -77,10 +77,10 @@ HeaderValueExtractorImpl::computeFragment(const Http::HeaderMap& headers) const return nullptr; } -ScopedRouteInfo::ScopedRouteInfo(envoy::config::route::v3::ScopedRouteConfiguration config_proto, +ScopedRouteInfo::ScopedRouteInfo(envoy::config::route::v3::ScopedRouteConfiguration&& config_proto, ConfigConstSharedPtr route_config) - : config_proto_(config_proto), route_config_(route_config), - config_hash_(MessageUtil::hash(config_proto)) { + : config_proto_(std::move(config_proto)), route_config_(route_config), + config_hash_(MessageUtil::hash(config_proto_)) { // TODO(stevenzzzz): Maybe worth a KeyBuilder abstraction when there are more than one type of // Fragment. for (const auto& fragment : config_proto_.key().fragments()) { diff --git a/source/common/router/scoped_config_impl.h b/source/common/router/scoped_config_impl.h index d7f8bd158ffa..ee134aaf66eb 100644 --- a/source/common/router/scoped_config_impl.h +++ b/source/common/router/scoped_config_impl.h @@ -77,7 +77,7 @@ class ScopeKeyBuilderImpl : public ScopeKeyBuilderBase { // ScopedRouteConfiguration and corresponding RouteConfigProvider. class ScopedRouteInfo { public: - ScopedRouteInfo(envoy::config::route::v3::ScopedRouteConfiguration config_proto, + ScopedRouteInfo(envoy::config::route::v3::ScopedRouteConfiguration&& config_proto, ConfigConstSharedPtr route_config); const ConfigConstSharedPtr& routeConfig() const { return route_config_; } @@ -89,9 +89,9 @@ class ScopedRouteInfo { uint64_t configHash() const { return config_hash_; } private: - envoy::config::route::v3::ScopedRouteConfiguration config_proto_; + const envoy::config::route::v3::ScopedRouteConfiguration config_proto_; ScopeKey scope_key_; - ConfigConstSharedPtr route_config_; + const ConfigConstSharedPtr route_config_; const uint64_t config_hash_; }; using ScopedRouteInfoConstSharedPtr = std::shared_ptr; diff --git a/source/common/router/scoped_rds.cc b/source/common/router/scoped_rds.cc index e459d0dc6be0..b60082593413 100644 --- a/source/common/router/scoped_rds.cc +++ b/source/common/router/scoped_rds.cc @@ -103,7 +103,7 @@ makeScopedRouteInfos(ProtobufTypes::ConstMessagePtrVector&& config_protos, config_provider_manager.routeConfigProviderManager().createStaticRouteConfigProvider( scoped_route_config.route_configuration(), factory_context, factory_context.messageValidationContext().staticValidationVisitor()); - scopes.push_back(std::make_shared(scoped_route_config, + scopes.push_back(std::make_shared(std::move(scoped_route_config), route_config_provider->configCast())); } diff --git a/source/common/runtime/runtime_features.cc b/source/common/runtime/runtime_features.cc index 54f067e2c63a..6ec39cd77dd3 100644 --- a/source/common/runtime/runtime_features.cc +++ b/source/common/runtime/runtime_features.cc @@ -159,6 +159,9 @@ FALSE_RUNTIME_GUARD(envoy_reloadable_features_explicit_internal_address_config); // compliance restrictions. FALSE_RUNTIME_GUARD(envoy_reloadable_features_google_grpc_disable_tls_13); +// A flag to enable the usage of the latest JSON formatter for logging. +// TODO(wbpcode): flip to true after Envoy v1.32.0 is released. +FALSE_RUNTIME_GUARD(envoy_reloadable_features_logging_with_fast_json_formatter); // TODO(yanavlasov): Flip to true after prod testing. // Controls whether a stream stays open when HTTP/2 or HTTP/3 upstream half closes // before downstream. diff --git a/source/common/upstream/upstream_impl.h b/source/common/upstream/upstream_impl.h index a3d43f7b969e..b3c93e451bb7 100644 --- a/source/common/upstream/upstream_impl.h +++ b/source/common/upstream/upstream_impl.h @@ -421,7 +421,9 @@ class HostImplBase : public Host, void setLbPolicyData(HostLbPolicyDataPtr lb_policy_data) override { lb_policy_data_ = std::move(lb_policy_data); } - const HostLbPolicyDataPtr& lbPolicyData() const override { return lb_policy_data_; } + OptRef lbPolicyData() const override { + return makeOptRefFromPtr(lb_policy_data_.get()); + } protected: static CreateConnectionData diff --git a/source/extensions/filters/network/http_connection_manager/config.cc b/source/extensions/filters/network/http_connection_manager/config.cc index 757c2439d422..f038ce870ae5 100644 --- a/source/extensions/filters/network/http_connection_manager/config.cc +++ b/source/extensions/filters/network/http_connection_manager/config.cc @@ -77,10 +77,16 @@ std::unique_ptr createInternalAddressConfig( return std::make_unique(config.internal_address_config(), creation_status); } - ENVOY_LOG_ONCE_MISC(warn, - "internal_address_config is not configured. The existing default behaviour " - "will trust RFC1918 IP addresses, but this will be changed in next release. " - "Please explictily config internal address config as the migration step."); + + if (!Runtime::runtimeFeatureEnabled( + "envoy.reloadable_features.explicit_internal_address_config")) { + ENVOY_LOG_ONCE_MISC( + warn, "internal_address_config is not configured. The existing default behaviour " + "will trust RFC1918 IP addresses, but this will be changed in next release. " + "Please explictily config internal address config as the migration step or " + "config the envoy.reloadable_features.explicit_internal_address_config to " + "true to untrust all ips by default"); + } return std::make_unique(); } @@ -511,12 +517,13 @@ HttpConnectionManagerConfig::HttpConnectionManagerConfig( } auto extension = factory->createExtension(extension_config.typed_config(), context_); - if (!extension) { + SET_AND_RETURN_IF_NOT_OK(extension.status(), creation_status); + if (!*extension) { creation_status = absl::InvalidArgumentError(fmt::format( "Original IP detection extension could not be created: '{}'", extension_config.name())); return; } - original_ip_detection_extensions_.push_back(extension); + original_ip_detection_extensions_.push_back(*extension); } const auto& header_mutation_extensions = config.early_header_mutation_extensions(); diff --git a/source/extensions/http/original_ip_detection/custom_header/config.cc b/source/extensions/http/original_ip_detection/custom_header/config.cc index d7df5dcdebfd..f5395ba679e2 100644 --- a/source/extensions/http/original_ip_detection/custom_header/config.cc +++ b/source/extensions/http/original_ip_detection/custom_header/config.cc @@ -13,7 +13,7 @@ namespace Http { namespace OriginalIPDetection { namespace CustomHeader { -Envoy::Http::OriginalIPDetectionSharedPtr +absl::StatusOr CustomHeaderIPDetectionFactory::createExtension(const Protobuf::Message& message, Server::Configuration::FactoryContext& context) { auto mptr = Envoy::Config::Utility::translateAnyToFactoryConfig( diff --git a/source/extensions/http/original_ip_detection/custom_header/config.h b/source/extensions/http/original_ip_detection/custom_header/config.h index 4c460c3a1caa..7a54b674d10e 100644 --- a/source/extensions/http/original_ip_detection/custom_header/config.h +++ b/source/extensions/http/original_ip_detection/custom_header/config.h @@ -18,7 +18,7 @@ namespace CustomHeader { */ class CustomHeaderIPDetectionFactory : public Envoy::Http::OriginalIPDetectionFactory { public: - Envoy::Http::OriginalIPDetectionSharedPtr + absl::StatusOr createExtension(const Protobuf::Message& message, Server::Configuration::FactoryContext& context) override; diff --git a/source/extensions/http/original_ip_detection/xff/config.cc b/source/extensions/http/original_ip_detection/xff/config.cc index 0f657239e3e8..3ebfa8deecef 100644 --- a/source/extensions/http/original_ip_detection/xff/config.cc +++ b/source/extensions/http/original_ip_detection/xff/config.cc @@ -13,7 +13,7 @@ namespace Http { namespace OriginalIPDetection { namespace Xff { -Envoy::Http::OriginalIPDetectionSharedPtr +absl::StatusOr XffIPDetectionFactory::createExtension(const Protobuf::Message& message, Server::Configuration::FactoryContext& context) { auto mptr = Envoy::Config::Utility::translateAnyToFactoryConfig( @@ -21,7 +21,7 @@ XffIPDetectionFactory::createExtension(const Protobuf::Message& message, const auto& proto_config = MessageUtil::downcastAndValidate< const envoy::extensions::http::original_ip_detection::xff::v3::XffConfig&>( *mptr, context.messageValidationVisitor()); - return std::make_shared(proto_config); + return XffIPDetection::create(proto_config); } REGISTER_FACTORY(XffIPDetectionFactory, Envoy::Http::OriginalIPDetectionFactory); diff --git a/source/extensions/http/original_ip_detection/xff/config.h b/source/extensions/http/original_ip_detection/xff/config.h index ce04edbbc0d4..539013269fba 100644 --- a/source/extensions/http/original_ip_detection/xff/config.h +++ b/source/extensions/http/original_ip_detection/xff/config.h @@ -18,7 +18,7 @@ namespace Xff { */ class XffIPDetectionFactory : public Envoy::Http::OriginalIPDetectionFactory { public: - Envoy::Http::OriginalIPDetectionSharedPtr + absl::StatusOr createExtension(const Protobuf::Message& message, Server::Configuration::FactoryContext& context) override; diff --git a/source/extensions/http/original_ip_detection/xff/xff.cc b/source/extensions/http/original_ip_detection/xff/xff.cc index b1c11cebabe9..3c3fdd60dddc 100644 --- a/source/extensions/http/original_ip_detection/xff/xff.cc +++ b/source/extensions/http/original_ip_detection/xff/xff.cc @@ -9,13 +9,19 @@ namespace Http { namespace OriginalIPDetection { namespace Xff { +absl::StatusOr> XffIPDetection::create( + const envoy::extensions::http::original_ip_detection::xff::v3::XffConfig& config) { + + if (config.has_xff_trusted_cidrs() && config.xff_num_trusted_hops() > 0) { + return absl::InvalidArgumentError("Cannot set both xff_num_trusted_hops and xff_trusted_cidrs"); + } + return std::unique_ptr(new XffIPDetection(config)); +} + XffIPDetection::XffIPDetection( const envoy::extensions::http::original_ip_detection::xff::v3::XffConfig& config) : xff_num_trusted_hops_(config.xff_num_trusted_hops()), skip_xff_append_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, skip_xff_append, true)) { - if (config.has_xff_trusted_cidrs() && config.xff_num_trusted_hops() > 0) { - throwEnvoyExceptionOrPanic("Cannot set both xff_num_trusted_hops and xff_trusted_cidrs"); - } if (config.has_xff_trusted_cidrs()) { xff_trusted_cidrs_.reserve(config.xff_trusted_cidrs().cidrs().size()); for (const envoy::config::core::v3::CidrRange& entry : config.xff_trusted_cidrs().cidrs()) { diff --git a/source/extensions/http/original_ip_detection/xff/xff.h b/source/extensions/http/original_ip_detection/xff/xff.h index d99388ea3b95..5608842f2ff5 100644 --- a/source/extensions/http/original_ip_detection/xff/xff.h +++ b/source/extensions/http/original_ip_detection/xff/xff.h @@ -19,7 +19,9 @@ namespace Xff { class XffIPDetection : public Envoy::Http::OriginalIPDetection, Logger::Loggable { public: - XffIPDetection(const envoy::extensions::http::original_ip_detection::xff::v3::XffConfig& config); + static absl::StatusOr> + create(const envoy::extensions::http::original_ip_detection::xff::v3::XffConfig& config); + XffIPDetection(uint32_t xff_num_trusted_hops, bool skip_xff_append); XffIPDetection(const std::vector xff_trusted_cidrs, bool skip_xff_append); @@ -27,7 +29,9 @@ class XffIPDetection : public Envoy::Http::OriginalIPDetection, Envoy::Http::OriginalIPDetectionResult detect(Envoy::Http::OriginalIPDetectionParams& params) override; -private: +protected: + XffIPDetection(const envoy::extensions::http::original_ip_detection::xff::v3::XffConfig& config); + const uint32_t xff_num_trusted_hops_; std::vector xff_trusted_cidrs_; const bool skip_xff_append_; diff --git a/source/extensions/load_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.cc b/source/extensions/load_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.cc index b11d60f351dc..87226753f089 100644 --- a/source/extensions/load_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.cc +++ b/source/extensions/load_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.cc @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -80,9 +81,8 @@ absl::Status ClientSideWeightedRoundRobinLoadBalancer::OrcaLoadReportHandler::on "LoadBalancerContext::OrcaLoadReportCb " "orca_load_report for {} report = {}", getHostAddress(host), orca_load_report.DebugString()); - const auto& lb_policy_data_ptr = host->lbPolicyData(); - auto* client_side_data = dynamic_cast(lb_policy_data_ptr.get()); - if (client_side_data == nullptr) { + auto client_side_data = host->typedLbPolicyData(); + if (!client_side_data.has_value()) { return absl::NotFoundError("Host does not have ClientSideLbPolicyData"); } return updateClientSideDataFromOrcaLoadReport(orca_load_report, *client_side_data); @@ -159,9 +159,9 @@ void ClientSideWeightedRoundRobinLoadBalancer::updateWeightsOnHosts(const HostVe void ClientSideWeightedRoundRobinLoadBalancer::addClientSideLbPolicyDataToHosts( const HostVector& hosts) { for (const auto& host_ptr : hosts) { - if (host_ptr->lbPolicyData() == nullptr) { + if (!host_ptr->lbPolicyData().has_value()) { ENVOY_LOG(trace, "Adding LB policy data to Host {}", getHostAddress(host_ptr.get())); - host_ptr->setLbPolicyData(std::make_shared()); + host_ptr->setLbPolicyData(std::make_unique()); } } } @@ -169,9 +169,8 @@ void ClientSideWeightedRoundRobinLoadBalancer::addClientSideLbPolicyDataToHosts( absl::optional ClientSideWeightedRoundRobinLoadBalancer::getClientSideWeightIfValidFromHost( const Host& host, MonotonicTime max_non_empty_since, MonotonicTime min_last_update_time) { - const auto& lb_policy_data_ptr = host.lbPolicyData(); - auto* client_side_data = dynamic_cast(lb_policy_data_ptr.get()); - if (client_side_data == nullptr) { + auto client_side_data = host.typedLbPolicyData(); + if (!client_side_data.has_value()) { ENVOY_LOG(trace, "Host does not have ClientSideHostLbPolicyData {}", getHostAddress(&host)); return std::nullopt; } diff --git a/test/common/formatter/substitution_formatter_fuzz_test.cc b/test/common/formatter/substitution_formatter_fuzz_test.cc index ed496d62a6da..7540c37f9387 100644 --- a/test/common/formatter/substitution_formatter_fuzz_test.cc +++ b/test/common/formatter/substitution_formatter_fuzz_test.cc @@ -1,3 +1,5 @@ +#include + #include "source/common/formatter/substitution_formatter.h" #include "test/common/formatter/substitution_formatter_fuzz.pb.validate.h" @@ -9,29 +11,86 @@ namespace Fuzz { namespace { DEFINE_PROTO_FUZZER(const test::common::substitution::TestCase& input) { + // Create formatter context. + Http::RequestHeaderMapPtr request_headers; + Http::ResponseHeaderMapPtr response_headers; + Http::ResponseTrailerMapPtr response_trailers; + std::unique_ptr stream_info; + MockTimeSystem time_system; + try { TestUtility::validate(input); - std::vector formatters = - Formatter::SubstitutionFormatParser::parse(input.format()); - const auto request_headers = - Fuzz::fromHeaders(input.request_headers()); - const auto response_headers = - Fuzz::fromHeaders(input.response_headers()); - const auto response_trailers = - Fuzz::fromHeaders(input.response_trailers()); - MockTimeSystem time_system; - const std::unique_ptr stream_info = - Fuzz::fromStreamInfo(input.stream_info(), time_system); - - const Formatter::HttpFormatterContext formatter_context{&request_headers, &response_headers, - &response_trailers}; - - for (const auto& it : formatters) { - it->formatWithContext(formatter_context, *stream_info); - } - ENVOY_LOG_MISC(trace, "Success"); + request_headers = std::make_unique( + Fuzz::fromHeaders(input.request_headers())); + response_headers = std::make_unique( + Fuzz::fromHeaders(input.response_headers())); + response_trailers = std::make_unique( + Fuzz::fromHeaders(input.response_trailers())); + stream_info = Fuzz::fromStreamInfo(input.stream_info(), time_system); } catch (const EnvoyException& e) { - ENVOY_LOG_MISC(debug, "EnvoyException: {}", e.what()); + ENVOY_LOG_MISC(debug, "Creating formatter context failed, EnvoyException: {}", e.what()); + return; + } + + const Formatter::HttpFormatterContext formatter_context{ + request_headers.get(), response_headers.get(), response_trailers.get()}; + + // Text formatter. + { + Formatter::FormatterPtr formatter; + try { + formatter = std::make_unique(input.format()); + } catch (const EnvoyException& e) { + ENVOY_LOG_MISC(debug, "TEXT formatter failed, EnvoyException: {}", e.what()); + return; + } + + // This should never throw. + formatter->formatWithContext(formatter_context, *stream_info); + ENVOY_LOG_MISC(trace, "TEXT formatter Success"); + } + + // JSON formatter. + { + + Formatter::FormatterPtr formatter; + Formatter::FormatterPtr typed_formatter; + + try { + // Create struct for JSON formatter. + ProtobufWkt::Struct struct_for_json_formatter; + TestUtility::loadFromYaml(fmt::format(R"EOF( + raw_bool_value: true + raw_nummber_value: 6 + nested_list: + - 14 + - "3.14" + - false + - "ok" + - '%REQ(key_1)%' + - '%REQ(error)%' + - {} + request_duration: '%REQUEST_DURATION%' + nested_level: + plain_string: plain_string_value + protocol: '%PROTOCOL%' + fuzz_format: {} + request_key: '%REQ(key_1)%_@!!!_"_%REQ(key_2)%' + )EOF", + input.format(), input.format()), + struct_for_json_formatter); + + // Create JSON formatter. + formatter = std::make_unique(struct_for_json_formatter, false); + } catch (const EnvoyException& e) { + ENVOY_LOG_MISC(debug, "JSON formatter failed, EnvoyException: {}", e.what()); + return; + } + + // This should never throw. + formatter->formatWithContext(formatter_context, *stream_info); + typed_formatter->formatWithContext(formatter_context, *stream_info); + ENVOY_LOG_MISC(trace, "JSON formatter Success"); } } diff --git a/test/common/formatter/substitution_formatter_speed_test.cc b/test/common/formatter/substitution_formatter_speed_test.cc index 30cfd83768d6..9e39bee30674 100644 --- a/test/common/formatter/substitution_formatter_speed_test.cc +++ b/test/common/formatter/substitution_formatter_speed_test.cc @@ -11,7 +11,7 @@ namespace Envoy { namespace { -std::unique_ptr makeJsonFormatter(bool typed) { +std::unique_ptr makeLegacyJsonFormatter(bool typed) { ProtobufWkt::Struct JsonLogFormat; const std::string format_yaml = R"EOF( remote_address: '%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%' @@ -26,7 +26,26 @@ std::unique_ptr makeJsonFormatter(bool type user-agent: '%REQ(USER-AGENT)%' )EOF"; TestUtility::loadFromYaml(format_yaml, JsonLogFormat); - return std::make_unique(JsonLogFormat, typed, false, false); + return std::make_unique(JsonLogFormat, typed, false, + false); +} + +std::unique_ptr makeJsonFormatter() { + ProtobufWkt::Struct JsonLogFormat; + const std::string format_yaml = R"EOF( + remote_address: '%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%' + start_time: '%START_TIME(%Y/%m/%dT%H:%M:%S%z %s)%' + method: '%REQ(:METHOD)%' + url: '%REQ(X-FORWARDED-PROTO)%://%REQ(:AUTHORITY)%%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%' + protocol: '%PROTOCOL%' + response_code: '%RESPONSE_CODE%' + bytes_sent: '%BYTES_SENT%' + duration: '%DURATION%' + referer: '%REQ(REFERER)%' + user-agent: '%REQ(USER-AGENT)%' + )EOF"; + TestUtility::loadFromYaml(format_yaml, JsonLogFormat); + return std::make_unique(JsonLogFormat, false); } std::unique_ptr makeStructFormatter(bool typed) { @@ -127,11 +146,24 @@ static void BM_TypedStructAccessLogFormatter(benchmark::State& state) { BENCHMARK(BM_TypedStructAccessLogFormatter); // NOLINTNEXTLINE(readability-identifier-naming) -static void BM_JsonAccessLogFormatter(benchmark::State& state) { +static void BM_LegacyJsonAccessLogFormatter(benchmark::State& state) { testing::NiceMock time_system; + std::unique_ptr stream_info = makeStreamInfo(time_system); + auto json_formatter = makeLegacyJsonFormatter(false); + size_t output_bytes = 0; + for (auto _ : state) { // NOLINT: Silences warning about dead store + output_bytes += json_formatter->formatWithContext({}, *stream_info).length(); + } + benchmark::DoNotOptimize(output_bytes); +} +BENCHMARK(BM_LegacyJsonAccessLogFormatter); + +// NOLINTNEXTLINE(readability-identifier-naming) +static void BM_LegacyTypedJsonAccessLogFormatter(benchmark::State& state) { + testing::NiceMock time_system; std::unique_ptr stream_info = makeStreamInfo(time_system); - std::unique_ptr json_formatter = makeJsonFormatter(false); + auto json_formatter = makeLegacyJsonFormatter(true); size_t output_bytes = 0; for (auto _ : state) { // NOLINT: Silences warning about dead store @@ -139,23 +171,22 @@ static void BM_JsonAccessLogFormatter(benchmark::State& state) { } benchmark::DoNotOptimize(output_bytes); } -BENCHMARK(BM_JsonAccessLogFormatter); +BENCHMARK(BM_LegacyTypedJsonAccessLogFormatter); // NOLINTNEXTLINE(readability-identifier-naming) -static void BM_TypedJsonAccessLogFormatter(benchmark::State& state) { +static void BM_JsonAccessLogFormatter(benchmark::State& state) { testing::NiceMock time_system; std::unique_ptr stream_info = makeStreamInfo(time_system); - std::unique_ptr typed_json_formatter = - makeJsonFormatter(true); + std::unique_ptr json_formatter = makeJsonFormatter(); size_t output_bytes = 0; for (auto _ : state) { // NOLINT: Silences warning about dead store - output_bytes += typed_json_formatter->formatWithContext({}, *stream_info).length(); + output_bytes += json_formatter->formatWithContext({}, *stream_info).length(); } benchmark::DoNotOptimize(output_bytes); } -BENCHMARK(BM_TypedJsonAccessLogFormatter); +BENCHMARK(BM_JsonAccessLogFormatter); // NOLINTNEXTLINE(readability-identifier-naming) static void BM_FormatterCommandParsing(benchmark::State& state) { diff --git a/test/common/formatter/substitution_formatter_test.cc b/test/common/formatter/substitution_formatter_test.cc index d7e1697ef56f..41b3e2fcbac4 100644 --- a/test/common/formatter/substitution_formatter_test.cc +++ b/test/common/formatter/substitution_formatter_test.cc @@ -4441,7 +4441,8 @@ TEST(SubstitutionFormatterTest, StructFormatterTypedTest) { TEST(SubstitutionFormatterTest, JsonFormatterTest) { NiceMock stream_info; - Http::TestRequestHeaderMapImpl request_header; + Http::TestRequestHeaderMapImpl request_header{{"key_1", "value_1"}, + {"key_2", R"(value_with_quotes_"_)"}}; Http::TestResponseHeaderMapImpl response_header; Http::TestResponseTrailerMapImpl response_trailer; std::string body; @@ -4460,26 +4461,93 @@ TEST(SubstitutionFormatterTest, JsonFormatterTest) { ProtobufWkt::Struct key_mapping; TestUtility::loadFromYaml(R"EOF( + raw_bool_value: true + raw_nummber_value: 6 + nested_list: + - 14 + - "3.14" + - false + - "ok" + - '%REQ(key_1)%' + - '%REQ(error)%' request_duration: '%REQUEST_DURATION%' nested_level: plain_string: plain_string_value protocol: '%PROTOCOL%' + request_key: '%REQ(key_1)%_@!!!_"_%REQ(key_2)%' )EOF", key_mapping); - JsonFormatterImpl formatter(key_mapping, false, false, false); const std::string expected = R"EOF({ - "request_duration": "5", + "raw_bool_value": true, + "raw_nummber_value": 6, + "nested_list": [ + 14, + "3.14", + false, + "ok", + "value_1", + null + ], + "request_duration": 5, "nested_level": { "plain_string": "plain_string_value", "protocol": "HTTP/1.1" - } + }, + "request_key": "value_1_@!!!_\"_value_with_quotes_\"_" })EOF"; + JsonFormatterImpl formatter(key_mapping, false); const std::string out_json = formatter.formatWithContext(formatter_context, stream_info); + std::cout << out_json << std::endl; EXPECT_TRUE(TestUtility::jsonStringEqual(out_json, expected)); } +TEST(SubstitutionFormatterTest, LegacyJsonFormatterTest) { + NiceMock stream_info; + Http::TestRequestHeaderMapImpl request_header{{"key_1", "value_1"}, + {"key_2", R"(value_with_quotes_"_)"}}; + Http::TestResponseHeaderMapImpl response_header; + Http::TestResponseTrailerMapImpl response_trailer; + std::string body; + + HttpFormatterContext formatter_context(&request_header, &response_header, &response_trailer, + body); + + envoy::config::core::v3::Metadata metadata; + populateMetadataTestData(metadata); + absl::optional protocol = Http::Protocol::Http11; + EXPECT_CALL(stream_info, protocol()).WillRepeatedly(Return(protocol)); + MockTimeSystem time_system; + EXPECT_CALL(time_system, monotonicTime) + .WillOnce(Return(MonotonicTime(std::chrono::nanoseconds(5000000)))); + stream_info.downstream_timing_.onLastDownstreamRxByteReceived(time_system); + + ProtobufWkt::Struct key_mapping; + TestUtility::loadFromYaml(R"EOF( + request_duration: '%REQUEST_DURATION%' + nested_level: + plain_string: plain_string_value + protocol: '%PROTOCOL%' + request_key: '%REQ(key_1)%_@!!!_"_%REQ(key_2)%' + )EOF", + key_mapping); + + const std::string expected = R"EOF({ + "request_duration": "5", + "nested_level": { + "plain_string": "plain_string_value", + "protocol": "HTTP/1.1" + }, + "request_key": "value_1_@!!!_\"_value_with_quotes_\"_" + })EOF"; + + LegacyJsonFormatterImpl legacy_formatter(key_mapping, false, false, false); + const std::string legacy_out_json = + legacy_formatter.formatWithContext(formatter_context, stream_info); + EXPECT_TRUE(TestUtility::jsonStringEqual(legacy_out_json, expected)); +} + TEST(SubstitutionFormatterTest, JsonFormatterWithOrderedPropertiesTest) { NiceMock stream_info; Http::TestRequestHeaderMapImpl request_header; @@ -4510,17 +4578,28 @@ TEST(SubstitutionFormatterTest, JsonFormatterWithOrderedPropertiesTest) { protocol: '%PROTOCOL%' )EOF", key_mapping); - JsonFormatterImpl formatter(key_mapping, false, false, true); const std::string expected = "{\"afield\":\"vala\",\"bfield\":\"valb\",\"nested_level\":" "{\"cfield\":\"valc\",\"plain_string\":\"plain_string_value\",\"protocol\":\"HTTP/1.1\"}," - "\"request_duration\":\"5\"}\n"; + "\"request_duration\":5}\n"; + // The formatter will always order the properties alphabetically. + JsonFormatterImpl formatter(key_mapping, false); const std::string out_json = formatter.formatWithContext(formatter_context, stream_info); - // Check string equality to verify the order. EXPECT_EQ(out_json, expected); + + const std::string legacy_expected = + "{\"afield\":\"vala\",\"bfield\":\"valb\",\"nested_level\":" + "{\"cfield\":\"valc\",\"plain_string\":\"plain_string_value\",\"protocol\":\"HTTP/1.1\"}," + "\"request_duration\":5.0}\n"; + + // The legacy formatter needs a flag to tell it to order the properties. + LegacyJsonFormatterImpl legacy_formatter(key_mapping, true, false, true); + const std::string legacy_out_json = + legacy_formatter.formatWithContext(formatter_context, stream_info); + EXPECT_EQ(legacy_out_json, legacy_expected); } TEST(SubstitutionFormatterTest, CompositeFormatterSuccess) { diff --git a/test/common/router/scoped_config_impl_test.cc b/test/common/router/scoped_config_impl_test.cc index 37d8a7fa6561..004b7b256251 100644 --- a/test/common/router/scoped_config_impl_test.cc +++ b/test/common/router/scoped_config_impl_test.cc @@ -384,19 +384,23 @@ TEST_F(ScopedRouteInfoTest, Creation) { // Tests that config hash changes if ScopedRouteConfiguration of the ScopedRouteInfo changes. TEST_F(ScopedRouteInfoTest, Hash) { - const envoy::config::route::v3::ScopedRouteConfiguration config_copy = scoped_route_config_; - info_ = std::make_unique(scoped_route_config_, route_config_); + envoy::config::route::v3::ScopedRouteConfiguration scoped_route_config1 = scoped_route_config_; + info_ = std::make_unique(std::move(scoped_route_config1), route_config_); EXPECT_EQ(info_->routeConfig().get(), route_config_.get()); - EXPECT_TRUE(TestUtility::protoEqual(info_->configProto(), config_copy)); + EXPECT_TRUE(TestUtility::protoEqual(info_->configProto(), scoped_route_config_)); EXPECT_EQ(info_->scopeName(), "foo_scope"); EXPECT_EQ(info_->scopeKey(), makeKey({"foo", "bar"})); - const auto info2 = std::make_unique(scoped_route_config_, route_config_); + envoy::config::route::v3::ScopedRouteConfiguration scoped_route_config2 = scoped_route_config_; + const auto info2 = + std::make_unique(std::move(scoped_route_config2), route_config_); ASSERT_EQ(info2->configHash(), info_->configHash()); // Mutate the config and hash should be different now. - scoped_route_config_.set_on_demand(true); - const auto info3 = std::make_unique(scoped_route_config_, route_config_); + envoy::config::route::v3::ScopedRouteConfiguration scoped_route_config3 = scoped_route_config_; + scoped_route_config3.set_on_demand(true); + const auto info3 = + std::make_unique(std::move(scoped_route_config3), route_config_); ASSERT_NE(info3->configHash(), info_->configHash()); } diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index 034c6fdefaf1..38917ad1be96 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -1629,17 +1629,17 @@ TEST_F(HostImplTest, Weight) { TEST_F(HostImplTest, HostLbPolicyData) { MockClusterMockPrioritySet cluster; HostSharedPtr host = makeTestHost(cluster.info_, "tcp://10.0.0.1:1234", simTime(), 1); - EXPECT_TRUE(host->lbPolicyData() == nullptr); + EXPECT_TRUE(!host->lbPolicyData().has_value()); class TestLbPolicyData : public Host::HostLbPolicyData { public: int foo = 42; }; - host->setLbPolicyData(std::make_shared()); - EXPECT_TRUE(host->lbPolicyData() != nullptr); - auto* test_policy_data = dynamic_cast(host->lbPolicyData().get()); - EXPECT_TRUE(test_policy_data != nullptr); + host->setLbPolicyData(std::make_unique()); + EXPECT_TRUE(host->lbPolicyData().has_value()); + auto test_policy_data = host->typedLbPolicyData(); + EXPECT_TRUE(test_policy_data.has_value()); EXPECT_EQ(test_policy_data->foo, 42); } diff --git a/test/extensions/filters/network/http_connection_manager/config_test.cc b/test/extensions/filters/network/http_connection_manager/config_test.cc index 06fa2cf5c194..9805d0f72c76 100644 --- a/test/extensions/filters/network/http_connection_manager/config_test.cc +++ b/test/extensions/filters/network/http_connection_manager/config_test.cc @@ -2586,7 +2586,7 @@ namespace { class OriginalIPDetectionExtensionNotCreatedFactory : public Http::OriginalIPDetectionFactory { public: - Http::OriginalIPDetectionSharedPtr + absl::StatusOr createExtension(const Protobuf::Message&, Server::Configuration::FactoryContext&) override { return nullptr; } diff --git a/test/extensions/http/original_ip_detection/custom_header/config_test.cc b/test/extensions/http/original_ip_detection/custom_header/config_test.cc index 83346697de76..0558ef8fedfd 100644 --- a/test/extensions/http/original_ip_detection/custom_header/config_test.cc +++ b/test/extensions/http/original_ip_detection/custom_header/config_test.cc @@ -29,7 +29,7 @@ TEST(CustomHeaderFactoryTest, Basic) { TestUtility::loadFromYaml(yaml, typed_config); NiceMock context; - EXPECT_NE(factory->createExtension(typed_config.typed_config(), context), nullptr); + EXPECT_NE(*factory->createExtension(typed_config.typed_config(), context), nullptr); } TEST(CustomHeaderFactoryTest, InvalidHeaderName) { @@ -47,7 +47,7 @@ TEST(CustomHeaderFactoryTest, InvalidHeaderName) { TestUtility::loadFromYaml(yaml, typed_config); NiceMock context; - EXPECT_THROW_WITH_REGEX(factory->createExtension(typed_config.typed_config(), context), + EXPECT_THROW_WITH_REGEX(*factory->createExtension(typed_config.typed_config(), context), EnvoyException, "Proto constraint validation failed.*does not match regex pattern.*"); } diff --git a/test/extensions/http/original_ip_detection/xff/config_test.cc b/test/extensions/http/original_ip_detection/xff/config_test.cc index 5a8ebaa3783b..cffdb5b1f8dc 100644 --- a/test/extensions/http/original_ip_detection/xff/config_test.cc +++ b/test/extensions/http/original_ip_detection/xff/config_test.cc @@ -29,7 +29,7 @@ TEST(CustomHeaderFactoryTest, Basic) { TestUtility::loadFromYaml(yaml, typed_config); NiceMock context; - EXPECT_NE(factory->createExtension(typed_config.typed_config(), context), nullptr); + EXPECT_NE(*factory->createExtension(typed_config.typed_config(), context), nullptr); } } // namespace Xff diff --git a/test/extensions/http/original_ip_detection/xff/xff_test.cc b/test/extensions/http/original_ip_detection/xff/xff_test.cc index 0fc3bc6145a8..761932bef851 100644 --- a/test/extensions/http/original_ip_detection/xff/xff_test.cc +++ b/test/extensions/http/original_ip_detection/xff/xff_test.cc @@ -18,7 +18,7 @@ class XffNumTrustedHopsTest : public testing::Test { XffNumTrustedHopsTest() { envoy::extensions::http::original_ip_detection::xff::v3::XffConfig config; config.set_xff_num_trusted_hops(1); - xff_extension_ = std::make_shared(config); + xff_extension_ = *XffIPDetection::create(config); } std::shared_ptr xff_extension_; @@ -60,7 +60,7 @@ class XffTrustedCidrsTest : public testing::Test { cidr3->set_address_prefix("2001:db8:7e57:1::"); cidr3->mutable_prefix_len()->set_value(64); config.mutable_skip_xff_append()->set_value(false); - xff_extension_ = std::make_shared(config); + xff_extension_ = *XffIPDetection::create(config); } std::shared_ptr xff_extension_; @@ -146,8 +146,8 @@ TEST(XffInvalidConfigTest, InvalidConfig) { cidr->set_address_prefix("192.0.2.0"); cidr->mutable_prefix_len()->set_value(24); - EXPECT_THROW_WITH_MESSAGE(std::make_shared(config), EnvoyException, - "Cannot set both xff_num_trusted_hops and xff_trusted_cidrs"); + EXPECT_EQ(XffIPDetection::create(config).status().message(), + "Cannot set both xff_num_trusted_hops and xff_trusted_cidrs"); } } // namespace Xff diff --git a/test/extensions/load_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb_test.cc b/test/extensions/load_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb_test.cc index 1db88cf400ed..f57aa3f1135f 100644 --- a/test/extensions/load_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb_test.cc +++ b/test/extensions/load_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb_test.cc @@ -92,12 +92,12 @@ void setHostClientSideWeight(HostSharedPtr& host, uint32_t weight, long long non_empty_since_seconds, long long last_update_time_seconds) { auto client_side_data = - std::make_shared( + std::make_unique( weight, /*non_empty_since=*/ MonotonicTime(std::chrono::seconds(non_empty_since_seconds)), /*last_update_time=*/ MonotonicTime(std::chrono::seconds(last_update_time_seconds))); - host->setLbPolicyData(client_side_data); + host->setLbPolicyData(std::move(client_side_data)); } class ClientSideWeightedRoundRobinLoadBalancerTest : public LoadBalancerTestBase { @@ -386,27 +386,28 @@ TEST(ClientSideWeightedRoundRobinLoadBalancerTest, TEST(ClientSideWeightedRoundRobinLoadBalancerTest, GetClientSideWeightIfValidFromHost_TooRecent) { NiceMock host; - auto client_side_data = - std::make_shared( + host.lb_policy_data_ = + std::make_unique( 42, /*non_empty_since=*/MonotonicTime(std::chrono::seconds(5)), /*last_update_time=*/MonotonicTime(std::chrono::seconds(10))); - host.lb_policy_data_ = client_side_data; // Non empty since is too recent (5 > 2). EXPECT_FALSE(ClientSideWeightedRoundRobinLoadBalancerFriend::getClientSideWeightIfValidFromHost( host, /*min_non_empty_since=*/MonotonicTime(std::chrono::seconds(2)), /*max_last_update_time=*/MonotonicTime(std::chrono::seconds(8)))); // non_empty_since_ is not updated. - EXPECT_EQ(client_side_data->non_empty_since_.load(), MonotonicTime(std::chrono::seconds(5))); + EXPECT_EQ( + host.typedLbPolicyData() + ->non_empty_since_.load(), + MonotonicTime(std::chrono::seconds(5))); } TEST(ClientSideWeightedRoundRobinLoadBalancerTest, GetClientSideWeightIfValidFromHost_TooStale) { NiceMock host; - auto client_side_data = - std::make_shared( + host.lb_policy_data_ = + std::make_unique( 42, /*non_empty_since=*/MonotonicTime(std::chrono::seconds(1)), /*last_update_time=*/MonotonicTime(std::chrono::seconds(7))); - host.lb_policy_data_ = client_side_data; // Last update time is too stale (7 < 8). EXPECT_FALSE(ClientSideWeightedRoundRobinLoadBalancerFriend::getClientSideWeightIfValidFromHost( host, @@ -414,17 +415,17 @@ TEST(ClientSideWeightedRoundRobinLoadBalancerTest, GetClientSideWeightIfValidFro /*max_last_update_time=*/MonotonicTime(std::chrono::seconds(8)))); // Also resets the non_empty_since_ time. EXPECT_EQ( - client_side_data->non_empty_since_.load(), + host.typedLbPolicyData() + ->non_empty_since_.load(), ClientSideWeightedRoundRobinLoadBalancer::ClientSideHostLbPolicyData::kDefaultNonEmptySince); } TEST(ClientSideWeightedRoundRobinLoadBalancerTest, GetClientSideWeightIfValidFromHost_Valid) { NiceMock host; - auto client_side_data = - std::make_shared( + host.lb_policy_data_ = + std::make_unique( 42, /*non_empty_since=*/MonotonicTime(std::chrono::seconds(1)), /*last_update_time=*/MonotonicTime(std::chrono::seconds(10))); - host.lb_policy_data_ = client_side_data; // Not empty since is not too recent (1 < 2) and last update time is not too // old (10 > 8). EXPECT_EQ(ClientSideWeightedRoundRobinLoadBalancerFriend::getClientSideWeightIfValidFromHost( @@ -434,7 +435,10 @@ TEST(ClientSideWeightedRoundRobinLoadBalancerTest, GetClientSideWeightIfValidFro .value(), 42); // non_empty_since_ is not updated. - EXPECT_EQ(client_side_data->non_empty_since_.load(), MonotonicTime(std::chrono::seconds(1))); + EXPECT_EQ( + host.typedLbPolicyData() + ->non_empty_since_.load(), + MonotonicTime(std::chrono::seconds(1))); } TEST(ClientSideWeightedRoundRobinLoadBalancerTest, diff --git a/test/mocks/upstream/host.cc b/test/mocks/upstream/host.cc index 6d623616da8c..b244d14800c1 100644 --- a/test/mocks/upstream/host.cc +++ b/test/mocks/upstream/host.cc @@ -60,7 +60,9 @@ MockHost::MockHost() : socket_factory_(new testing::NiceMock OptRef { + return makeOptRefFromPtr(lb_policy_data_.get()); + })); } MockHost::~MockHost() = default; diff --git a/test/mocks/upstream/host.h b/test/mocks/upstream/host.h index 32619c16af8f..74c605aaf1b7 100644 --- a/test/mocks/upstream/host.h +++ b/test/mocks/upstream/host.h @@ -210,7 +210,7 @@ class MockHostLight : public Host { MOCK_METHOD(bool, warmed, (), (const)); MOCK_METHOD(absl::optional, lastHcPassTime, (), (const)); MOCK_METHOD(void, setLbPolicyData, (HostLbPolicyDataPtr lb_policy_data)); - MOCK_METHOD(const HostLbPolicyDataPtr&, lbPolicyData, (), (const)); + MOCK_METHOD(OptRef, lbPolicyData, (), (const)); bool disable_active_health_check_ = false; }; diff --git a/test/per_file_coverage.sh b/test/per_file_coverage.sh index c5bc35cf786e..a31b15d9fef3 100755 --- a/test/per_file_coverage.sh +++ b/test/per_file_coverage.sh @@ -35,7 +35,6 @@ declare -a KNOWN_LOW_COVERAGE=( "source/extensions/filters/http/grpc_json_transcoder:94.2" # TODO(#28232) "source/extensions/filters/http/ip_tagging:88.2" "source/extensions/filters/http/kill_request:91.7" # Death tests don't report LCOV -"source/extensions/filters/http/wasm:1.3" # Disabled due to issue (#24164) "source/extensions/filters/listener/original_src:92.1" "source/extensions/filters/network/mongo_proxy:96.1" "source/extensions/filters/network/sni_cluster:88.9" diff --git a/tools/base/requirements.txt b/tools/base/requirements.txt index ed54220147e4..505741eccdaf 100644 --- a/tools/base/requirements.txt +++ b/tools/base/requirements.txt @@ -1515,99 +1515,99 @@ yapf==0.40.2 \ # via # -r requirements.in # envoy-code-check -yarl==1.12.1 \ - --hash=sha256:0103c52f8dfe5d573c856322149ddcd6d28f51b4d4a3ee5c4b3c1b0a05c3d034 \ - --hash=sha256:01549468858b87d36f967c97d02e6e54106f444aeb947ed76f8f71f85ed07cec \ - --hash=sha256:0274b1b7a9c9c32b7bf250583e673ff99fb9fccb389215841e2652d9982de740 \ - --hash=sha256:0ac33d22b2604b020569a82d5f8a03ba637ba42cc1adf31f616af70baf81710b \ - --hash=sha256:0d0a5e87bc48d76dfcfc16295201e9812d5f33d55b4a0b7cad1025b92bf8b91b \ - --hash=sha256:10b690cd78cbaca2f96a7462f303fdd2b596d3978b49892e4b05a7567c591572 \ - --hash=sha256:126309c0f52a2219b3d1048aca00766429a1346596b186d51d9fa5d2070b7b13 \ - --hash=sha256:15871130439ad10abb25a4631120d60391aa762b85fcab971411e556247210a0 \ - --hash=sha256:17d4dc4ff47893a06737b8788ed2ba2f5ac4e8bb40281c8603920f7d011d5bdd \ - --hash=sha256:18c2a7757561f05439c243f517dbbb174cadfae3a72dee4ae7c693f5b336570f \ - --hash=sha256:1d4017e78fb22bc797c089b746230ad78ecd3cdb215bc0bd61cb72b5867da57e \ - --hash=sha256:1f50a37aeeb5179d293465e522fd686080928c4d89e0ff215e1f963405ec4def \ - --hash=sha256:20d817c0893191b2ab0ba30b45b77761e8dfec30a029b7c7063055ca71157f84 \ - --hash=sha256:22839d1d1eab9e4b427828a88a22beb86f67c14d8ff81175505f1cc8493f3500 \ - --hash=sha256:22dda2799c8d39041d731e02bf7690f0ef34f1691d9ac9dfcb98dd1e94c8b058 \ - --hash=sha256:2376d8cf506dffd0e5f2391025ae8675b09711016656590cb03b55894161fcfa \ - --hash=sha256:24197ba3114cc85ddd4091e19b2ddc62650f2e4a899e51b074dfd52d56cf8c72 \ - --hash=sha256:24416bb5e221e29ddf8aac5b97e94e635ca2c5be44a1617ad6fe32556df44294 \ - --hash=sha256:2631c9d7386bd2d4ce24ecc6ebf9ae90b3efd713d588d90504eaa77fec4dba01 \ - --hash=sha256:28389a68981676bf74e2e199fe42f35d1aa27a9c98e3a03e6f58d2d3d054afe1 \ - --hash=sha256:2aee7594d2c2221c717a8e394bbed4740029df4c0211ceb0f04815686e99c795 \ - --hash=sha256:2e430ac432f969ef21770645743611c1618362309e3ad7cab45acd1ad1a540ff \ - --hash=sha256:2e912b282466444023610e4498e3795c10e7cfd641744524876239fcf01d538d \ - --hash=sha256:30ffc046ebddccb3c4cac72c1a3e1bc343492336f3ca86d24672e90ccc5e788a \ - --hash=sha256:319c206e83e46ec2421b25b300c8482b6fe8a018baca246be308c736d9dab267 \ - --hash=sha256:326b8a079a9afcac0575971e56dabdf7abb2ea89a893e6949b77adfeb058b50e \ - --hash=sha256:36ee0115b9edca904153a66bb74a9ff1ce38caff015de94eadfb9ba8e6ecd317 \ - --hash=sha256:3e26e64f42bce5ddf9002092b2c37b13071c2e6413d5c05f9fa9de58ed2f7749 \ - --hash=sha256:4ea99e64b2ad2635e0f0597b63f5ea6c374791ff2fa81cdd4bad8ed9f047f56f \ - --hash=sha256:501a1576716032cc6d48c7c47bcdc42d682273415a8f2908e7e72cb4625801f3 \ - --hash=sha256:54c8cee662b5f8c30ad7eedfc26123f845f007798e4ff1001d9528fe959fd23c \ - --hash=sha256:595bbcdbfc4a9c6989d7489dca8510cba053ff46b16c84ffd95ac8e90711d419 \ - --hash=sha256:5b860055199aec8d6fe4dcee3c5196ce506ca198a50aab0059ffd26e8e815828 \ - --hash=sha256:5c667b383529520b8dd6bd496fc318678320cb2a6062fdfe6d3618da6b8790f6 \ - --hash=sha256:5fb475a4cdde582c9528bb412b98f899680492daaba318231e96f1a0a1bb0d53 \ - --hash=sha256:607d12f0901f6419a8adceb139847c42c83864b85371f58270e42753f9780fa6 \ - --hash=sha256:64c5b0f2b937fe40d0967516eee5504b23cb247b8b7ffeba7213a467d9646fdc \ - --hash=sha256:664380c7ed524a280b6a2d5d9126389c3e96cd6e88986cdb42ca72baa27421d6 \ - --hash=sha256:6af871f70cfd5b528bd322c65793b5fd5659858cdfaa35fbe563fb99b667ed1f \ - --hash=sha256:6c89894cc6f6ddd993813e79244b36b215c14f65f9e4f1660b1f2ba9e5594b95 \ - --hash=sha256:6dee0496d5f1a8f57f0f28a16f81a2033fc057a2cf9cd710742d11828f8c80e2 \ - --hash=sha256:6e9a9f50892153bad5046c2a6df153224aa6f0573a5a8ab44fc54a1e886f6e21 \ - --hash=sha256:712ba8722c0699daf186de089ddc4677651eb9875ed7447b2ad50697522cbdd9 \ - --hash=sha256:717f185086bb9d817d4537dd18d5df5d657598cd00e6fc22e4d54d84de266c1d \ - --hash=sha256:71978ba778948760cff528235c951ea0ef7a4f9c84ac5a49975f8540f76c3f73 \ - --hash=sha256:71af3766bb46738d12cc288d9b8de7ef6f79c31fd62757e2b8a505fe3680b27f \ - --hash=sha256:73a183042ae0918c82ce2df38c3db2409b0eeae88e3afdfc80fb67471a95b33b \ - --hash=sha256:7564525a4673fde53dee7d4c307a961c0951918f0b8c7f09b2c9e02067cf6504 \ - --hash=sha256:76a59d1b63de859398bc7764c860a769499511463c1232155061fe0147f13e01 \ - --hash=sha256:7e9905fc2dc1319e4c39837b906a024cf71b1261cc66b0cd89678f779c0c61f5 \ - --hash=sha256:8112f640a4f7e7bf59f7cabf0d47a29b8977528c521d73a64d5cc9e99e48a174 \ - --hash=sha256:835010cc17d0020e7931d39e487d72c8e01c98e669b6896a8b8c9aa8ca69a949 \ - --hash=sha256:838dde2cb570cfbb4cab8a876a0974e8b90973ea40b3ac27a79b8a74c8a2db15 \ - --hash=sha256:8d31dd0245d88cf7239e96e8f2a99f815b06e458a5854150f8e6f0e61618d41b \ - --hash=sha256:96b34830bd6825ca0220bf005ea99ac83eb9ce51301ddb882dcf613ae6cd95fb \ - --hash=sha256:96c8ff1e1dd680e38af0887927cab407a4e51d84a5f02ae3d6eb87233036c763 \ - --hash=sha256:9a7ee79183f0b17dcede8b6723e7da2ded529cf159a878214be9a5d3098f5b1e \ - --hash=sha256:a3e2aff8b822ab0e0bdbed9f50494b3a35629c4b9488ae391659973a37a9f53f \ - --hash=sha256:a4f3ab9eb8ab2d585ece959c48d234f7b39ac0ca1954a34d8b8e58a52064bdb3 \ - --hash=sha256:a8b54949267bd5704324397efe9fbb6aa306466dee067550964e994d309db5f1 \ - --hash=sha256:a96198d5d26f40557d986c1253bfe0e02d18c9d9b93cf389daf1a3c9f7c755fa \ - --hash=sha256:aebbd47df77190ada603157f0b3670d578c110c31746ecc5875c394fdcc59a99 \ - --hash=sha256:af1107299cef049ad00a93df4809517be432283a0847bcae48343ebe5ea340dc \ - --hash=sha256:b63465b53baeaf2122a337d4ab57d6bbdd09fcadceb17a974cfa8a0300ad9c67 \ - --hash=sha256:ba1c779b45a399cc25f511c681016626f69e51e45b9d350d7581998722825af9 \ - --hash=sha256:bce00f3b1f7f644faae89677ca68645ed5365f1c7f874fdd5ebf730a69640d38 \ - --hash=sha256:bfdf419bf5d3644f94cd7052954fc233522f5a1b371fc0b00219ebd9c14d5798 \ - --hash=sha256:c1caa5763d1770216596e0a71b5567f27aac28c95992110212c108ec74589a48 \ - --hash=sha256:c3e4e1f7b08d1ec6b685ccd3e2d762219c550164fbf524498532e39f9413436e \ - --hash=sha256:c85ab016e96a975afbdb9d49ca90f3bca9920ef27c64300843fe91c3d59d8d20 \ - --hash=sha256:c924deab8105f86980983eced740433fb7554a7f66db73991affa4eda99d5402 \ - --hash=sha256:d4f818f6371970d6a5d1e42878389bbfb69dcde631e4bbac5ec1cb11158565ca \ - --hash=sha256:d920401941cb898ef089422e889759dd403309eb370d0e54f1bdf6ca07fef603 \ - --hash=sha256:da045bd1147d12bd43fb032296640a7cc17a7f2eaba67495988362e99db24fd2 \ - --hash=sha256:dc3192a81ecd5ff954cecd690327badd5a84d00b877e1573f7c9097ce13e5bfb \ - --hash=sha256:ddae504cfb556fe220efae65e35be63cd11e3c314b202723fc2119ce19f0ca2e \ - --hash=sha256:de4544b1fb29cf14870c4e2b8a897c0242449f5dcebd3e0366aa0aa3cf58a23a \ - --hash=sha256:dea360778e0668a7ad25d7727d03364de8a45bfd5d808f81253516b9f2217765 \ - --hash=sha256:e2254fe137c4a360b0a13173a56444f756252c9283ba4d267ca8e9081cd140ea \ - --hash=sha256:e64f0421892a207d3780903085c1b04efeb53b16803b23d947de5a7261b71355 \ - --hash=sha256:e97a29b37830ba1262d8dfd48ddb5b28ad4d3ebecc5d93a9c7591d98641ec737 \ - --hash=sha256:eacbcf30efaca7dc5cb264228ffecdb95fdb1e715b1ec937c0ce6b734161e0c8 \ - --hash=sha256:eee5ff934b0c9f4537ff9596169d56cab1890918004791a7a06b879b3ba2a7ef \ - --hash=sha256:eff6bac402719c14e17efe845d6b98593c56c843aca6def72080fbede755fd1f \ - --hash=sha256:f10954b233d4df5cc3137ffa5ced97f8894152df817e5d149bf05a0ef2ab8134 \ - --hash=sha256:f23bb1a7a6e8e8b612a164fdd08e683bcc16c76f928d6dbb7bdbee2374fbfee6 \ - --hash=sha256:f494c01b28645c431239863cb17af8b8d15b93b0d697a0320d5dd34cd9d7c2fa \ - --hash=sha256:f6a071d2c3d39b4104f94fc08ab349e9b19b951ad4b8e3b6d7ea92d6ef7ccaf8 \ - --hash=sha256:f736f54565f8dd7e3ab664fef2bc461d7593a389a7f28d4904af8d55a91bd55f \ - --hash=sha256:f8981a94a27ac520a398302afb74ae2c0be1c3d2d215c75c582186a006c9e7b0 \ - --hash=sha256:fd24996e12e1ba7c397c44be75ca299da14cde34d74bc5508cce233676cc68d0 \ - --hash=sha256:ff54340fc1129e8e181827e2234af3ff659b4f17d9bbe77f43bc19e6577fadec +yarl==1.13.0 \ + --hash=sha256:01953b5686e5868fd0d8eaea4e484482c158597b8ddb9d9d4d048303fa3334c7 \ + --hash=sha256:01d3941d416e71ce65f33393beb50e93c1c9e8e516971b6653c96df6eb599a2c \ + --hash=sha256:02f117a63d11c8c2ada229029f8bb444a811e62e5041da962de548f26ac2c40f \ + --hash=sha256:0675a9cf65176e11692b20a516d5f744849251aa24024f422582d2d1bf7c8c82 \ + --hash=sha256:08037790f973367431b9406a7b9d940e872cca12e081bce3b7cea068daf81f0a \ + --hash=sha256:08a3b0b8d10092dade46424fe775f2c9bc32e5a985fdd6afe410fe28598db6b2 \ + --hash=sha256:08d15aff3477fecb7a469d1fdf5939a686fbc5a16858022897d3e9fc99301f19 \ + --hash=sha256:0b489858642e4e92203941a8fdeeb6373c0535aa986200b22f84d4b39cd602ba \ + --hash=sha256:0bd3caf554a52da78ec08415ebedeb6b9636436ca2afda9b5b9ff4a533478940 \ + --hash=sha256:0db15ce35dfd100bc9ab40173f143fbea26c84d7458d63206934fe5548fae25d \ + --hash=sha256:1129737da2291c9952a93c015e73583dd66054f3ae991c8674f6e39c46d95dd3 \ + --hash=sha256:12c92576633027f297c26e52aba89f6363b460f483d85cf7c14216eb55d06d02 \ + --hash=sha256:13a9cd39e47ca4dc25139d3c63fe0dc6acf1b24f9d94d3b5197ac578fbfd84bf \ + --hash=sha256:144b9e9164f21da81731c970dbda52245b343c0f67f3609d71013dd4d0db9ebf \ + --hash=sha256:1932c7bfa537f89ad5ca3d1e7e05de3388bb9e893230a384159fb974f6e9f90c \ + --hash=sha256:24b78a1f57780eeeb17f5e1be851ab9fa951b98811e1bb4b5a53f74eec3e2666 \ + --hash=sha256:26214b0a9b8f4b7b04e67eee94a82c9b4e5c721f4d1ce7e8c87c78f0809b7684 \ + --hash=sha256:2842a89b697d8ca3dda6a25b4e4d835d14afe25a315c8a79dbdf5f70edfd0960 \ + --hash=sha256:2cec7b52903dcf9008311167036775346dcb093bb15ed7ec876debc3095e7dab \ + --hash=sha256:2d7a44ae252efb0fcd79ac0997416721a44345f53e5aec4a24f489d983aa00e3 \ + --hash=sha256:2f6f4a352d0beea5dd39315ab16fc26f0122d13457a7e65ad4f06c7961dcf87a \ + --hash=sha256:31748bee7078db26008bf94d39693c682a26b5c3a80a67194a4c9c8fe3b5cf47 \ + --hash=sha256:33e2f5ef965e69a1f2a1b0071a70c4616157da5a5478f3c2f6e185e06c56a322 \ + --hash=sha256:3590ed9c7477059aea067a58ec87b433bbd47a2ceb67703b1098cca1ba075f0d \ + --hash=sha256:3628e4e572b1db95285a72c4be102356f2dfc6214d9f126de975fd51b517ae55 \ + --hash=sha256:37049eb26d637a5b2f00562f65aad679f5d231c4c044edcd88320542ad66a2d9 \ + --hash=sha256:38a3b742c923fe2cab7d2e2c67220d17da8d0433e8bfe038356167e697ef5524 \ + --hash=sha256:3a9b2650425b2ab9cc68865978963601b3c2414e1d94ef04f193dd5865e1bd79 \ + --hash=sha256:3ff602aa84420b301c083ae7f07df858ae8e371bf3be294397bda3e0b27c6290 \ + --hash=sha256:419c22b419034b4ee3ba1c27cbbfef01ca8d646f9292f614f008093143334cdc \ + --hash=sha256:4483680e129b2a4250be20947b554cd5f7140fa9e5a1e4f1f42717cf91f8676a \ + --hash=sha256:49bee8c99586482a238a7b2ec0ef94e5f186bfdbb8204d14a3dd31867b3875ce \ + --hash=sha256:4c73e0f8375b75806b8771890580566a2e6135e6785250840c4f6c45b69eb72d \ + --hash=sha256:4ffd8a9758b5df7401a49d50e76491f4c582cf7350365439563062cdff45bf16 \ + --hash=sha256:517f9d90ca0224bb7002266eba6e70d8fcc8b1d0c9321de2407e41344413ed46 \ + --hash=sha256:52b7bb09bb48f7855d574480e2efc0c30d31cab4e6ffc6203e2f7ffbf2e4496a \ + --hash=sha256:5378cb60f4209505f6aa60423c174336bd7b22e0d8beb87a2a99ad50787f1341 \ + --hash=sha256:5540b4896b244a6539f22b613b32b5d1b737e08011aa4ed56644cb0519d687df \ + --hash=sha256:561a5f6c054927cf5a993dd7b032aeebc10644419e65db7dd6bdc0b848806e65 \ + --hash=sha256:580fdb2ea48a40bcaa709ee0dc71f64e7a8f23b44356cc18cd9ce55dc3bc3212 \ + --hash=sha256:6072ff51eeb7938ecac35bf24fc465be00e75217eaa1ffad3cc7620accc0f6f4 \ + --hash=sha256:612bd8d2267558bea36347e4e6e3a96f436bdc5c011f1437824be4f2e3abc5e1 \ + --hash=sha256:66c028066be36d54e7a0a38e832302b23222e75db7e65ed862dc94effc8ef062 \ + --hash=sha256:73777f145cd591e1377bf8d8a97e5f8e39c9742ad0f100c898bba1f963aef662 \ + --hash=sha256:784d6e50ea96b3bbb078eb7b40d8c0e3674c2f12da4f0061f889b2cfdbab8f37 \ + --hash=sha256:79de5f8432b53d1261d92761f71dfab5fc7e1c75faa12a3535c27e681dacfa9d \ + --hash=sha256:801fb5dfc05910cd5ef4806726e2129d8c9a16cdfa26a8166697da0861e59dfc \ + --hash=sha256:8986fa2be78193dc8b8c27bd0d3667fe612f7232844872714c4200499d5225ca \ + --hash=sha256:8a67f20e97462dee8a89e9b997a78932959d2ed991e8f709514cb4160143e7b1 \ + --hash=sha256:8ab16c9e94726fdfcbf5b37a641c9d9d0b35cc31f286a2c3b9cad6451cb53b2b \ + --hash=sha256:91251614cca1ba4ab0507f1ba5f5a44e17a5e9a4c7f0308ea441a994bdac3fc7 \ + --hash=sha256:92a26956d268ad52bd2329c2c674890fe9e8669b41d83ed136e7037b1a29808e \ + --hash=sha256:92abbe37e3fb08935e0e95ac5f83f7b286a6f2575f542225ec7afde405ed1fa1 \ + --hash=sha256:9671d0d65f86e0a0eee59c5b05e381c44e3d15c36c2a67da247d5d82875b4e4e \ + --hash=sha256:9d2845f1a37438a8e11e4fcbbf6ffd64bc94dc9cb8c815f72d0eb6f6c622deb0 \ + --hash=sha256:a9a1a600e8449f3a24bc7dca513be8d69db173fe842e8332a7318b5b8757a6af \ + --hash=sha256:aa187a8599e0425f26b25987d884a8b67deb5565f1c450c3a6e8d3de2cdc8715 \ + --hash=sha256:aaf10e525e461f43831d82149d904f35929d89f3ccd65beaf7422aecd500dd39 \ + --hash=sha256:ab3ee57b25ce15f79ade27b7dfb5e678af26e4b93be5a4e22655acd9d40b81ba \ + --hash=sha256:acf27399c94270103d68f86118a183008d601e4c2c3a7e98dcde0e3b0163132f \ + --hash=sha256:acf8c219a59df22609cfaff4a7158a0946f273e3b03a5385f1fdd502496f0cff \ + --hash=sha256:b536c2ac042add7f276d4e5857b08364fc32f28e02add153f6f214de50f12d07 \ + --hash=sha256:b9648e5ae280babcac867b16e845ce51ed21f8c43bced2ca40cff7eee983d6d4 \ + --hash=sha256:bcb374db7a609484941c01380c1450728ec84d9c3e68cd9a5feaecb52626c4be \ + --hash=sha256:be828e92ae67a21d6a252aecd65668dddbf3bb5d5278660be607647335001119 \ + --hash=sha256:bf7a9b31729b97985d4a796808859dfd0e37b55f1ca948d46a568e56e51dd8fb \ + --hash=sha256:bff0d468664cdf7b2a6bfd5e17d4a7025edb52df12e0e6e17223387b421d425c \ + --hash=sha256:c2518660bd8166e770b76ce92514b491b8720ae7e7f5f975cd888b1592894d2c \ + --hash=sha256:c7d35ff2a5a51bc6d40112cdb4ca3fd9636482ce8c6ceeeee2301e34f7ed7556 \ + --hash=sha256:ca71238af0d247d07747cb7202a9359e6e1d6d9e277041e1ad2d9f36b3a111a6 \ + --hash=sha256:cdcdd49136d423ee5234c9360eae7063d3120a429ee984d7d9da821c012da4d7 \ + --hash=sha256:cf4f3a87bd52f8f33b0155cd0f6f22bdf2092d88c6c6acbb1aee3bc206ecbe35 \ + --hash=sha256:d04ea92a3643a9bb28aa6954fff718342caab2cc3d25d0160fe16e26c4a9acb7 \ + --hash=sha256:d42227711a4180d0c22cec30fd81d263d7bb378389d8e70b5f4c597e8abae202 \ + --hash=sha256:d78ebad57152d301284761b03a708aeac99c946a64ba967d47cbcc040e36688b \ + --hash=sha256:d807417ceebafb7ce18085a1205d28e8fcb1435a43197d7aa3fab98f5bfec5ef \ + --hash=sha256:d95fcc9508390db73a0f1c7e78d9a1b1a3532a3f34ceff97c0b3b04140fbe6e4 \ + --hash=sha256:db463fce425f935eee04a9182c74fdf9ed90d3bd2079d4a17f8fb7a2d7c11009 \ + --hash=sha256:db90702060b1cdb7c7609d04df5f68a12fd5581d013ad379e58e0c2e651d92b8 \ + --hash=sha256:de97ee57e00a82ebb8c378fc73c5d9a773e4c2cec8079ff34ebfef61c8ba5b11 \ + --hash=sha256:deb70c006be548076d628630aad9a3ef3a1b2c28aaa14b395cf0939b9124252e \ + --hash=sha256:e3b4293f02129cc2f5068f3687ef294846a79c9d19fabaa9bfdfeeebae11c001 \ + --hash=sha256:e480a12cec58009eeaeee7f48728dc8f629f8e0f280d84957d42c361969d84da \ + --hash=sha256:e4dddf99a853b3f60f3ce6363fb1ad94606113743cf653f116a38edd839a4461 \ + --hash=sha256:e5462756fb34c884ca9d4875b6d2ec80957a767123151c467c97a9b423617048 \ + --hash=sha256:e557e2681b47a0ecfdfbea44743b3184d94d31d5ce0e4b13ff64ce227a40f86e \ + --hash=sha256:ebb2236f8098205f59774a28e25a84601a4beb3e974157d418ee6c470d73e0dc \ + --hash=sha256:f3ef76df654f3547dcb76ba550f9ca59826588eecc6bd7df16937c620df32060 \ + --hash=sha256:f603216d62e9680bfac7fb168ef9673fd98abbb50c43e73d97615dfa1afebf57 \ + --hash=sha256:f997004ff530b5381290e82b212a93bd420fefe5a605872dc16fc7e4a7f4251e \ + --hash=sha256:fda4404bbb6f91e327827f4483d52fe24f02f92de91217954cf51b1cb9ee9c41 \ + --hash=sha256:fe6946c3cbcfbed67c5e50dae49baff82ad054aaa10ff7a4db8dfac646b7b479 # via # -r requirements.in # aiohttp diff --git a/tools/code_format/config.yaml b/tools/code_format/config.yaml index 5b1d73eda685..3d117d0f634e 100644 --- a/tools/code_format/config.yaml +++ b/tools/code_format/config.yaml @@ -221,7 +221,6 @@ paths: - source/extensions/http/custom_response - source/extensions/http/early_header_mutation - source/extensions/http/injected_credentials - - source/extensions/http/original_ip_detection - source/extensions/http/stateful_session - source/extensions/io_socket/user_space - source/extensions/key_value